Fixed EndOfStreamException from occurring sometimes