Fix bytesToRead becoming zero in read after ungetc