diff --git a/src/SFtp.cc b/src/SFtp.cc
index 0b422fb..db1b705 100644
--- a/src/SFtp.cc
+++ b/src/SFtp.cc
@@ -1149,7 +1149,7 @@ int SFtp::Read(void *buf,int size)
return error_code;
if(mode==CLOSED)
return 0;
- if(state==DONE)
+ if(state==DONE && !(file_buf && file_buf->Size()>0))
return 0; // eof
if(state==FILE_RECV)
{
@@ -1161,7 +1161,10 @@ int SFtp::Read(void *buf,int size)
if(entity_size<0 || request_pos<entity_size || RespQueueSize()<2)
RequestMoreData();
}
+ }
+ if(file_buf && file_buf->Size()>0)
+ {
const char *buf1;
int size1;
file_buf->Get(&buf1,&size1);