Throw IOException if there was an error (-1) returned when reading from
input stream.