Fix wrong typecast from int to char without testing EOF