Issue UnexpectedError only when fgets returned null after reading some data.

If nothing was read, then fgets encountered eof before reading any data,
which can happen.
Fix whitespaces.