fixing EOFException logic in readBytes