An EOF check has slipped...

There's another check for EOF which needs to be enclosed inside the number of characters read check.