Fix check for EOF