EOF is not an error situation. You should return 0.