Fix the return value of fgets().

It's a bug that occurs in every files ending with a newline. When encountering EOF, which is not discovered in previous runs, and there's no data available, it should return 0 to signal the EOF.