changed char to int (because of EOF)