fixed early EOF condition