read a byte and not a char in EOF check

Reading a char can fail when this char gets decoded to utf8.