If you want to read to the end of the file, check for stream.eof(), as was said before