private void Read(byte[] buffer, int offset, int count) { var bytesRead = stream.Read(buffer, offset, count); if (bytesRead != count) { throw new EndOfStreamException(); } }