EOF is outside the value range of char on architectures with unsigned
char like ARM. Check for EOF explicitly.