Fix bug with upload. Check for condition eof