Fix file end detection.