Troubleshooting Exceptions: System.IO.EndOfStreamException 

An EndOfStreamException exception is thrown when there is an attempt to read past the end of a stream.

Check whether the end of the file has been reached before reading.

Use the Peek method to check the end of the file before reading from the stream.

Show: