Error: Io exception: Got minus one from a read call