When EOF, and there is an error, handle correctly.