fixed not reading until end of input bug