News for hackers. Stuff that matters.
Re:You’re better off using Exceptions by gwbas1c on Monday February 03, 2020 @02:47PM (#22228174)
> don’t include logic for checking for EOF. Let the exception handler catch it where the file will be closed

What happens if the file is smaller than you anticipate?

That's why exceptions aren't used for flow control.

Re:You’re better off using Exceptions by waynecochran on Monday February 03, 2020 @05:06PM (#22229780)
Simply count bytes as they are read. In the exception handler check to see if the count matches the expected value. Clean.