private void FlushWrite()
{
Debug.Assert(_readPos == 0 && _readLen == 0,
"BufferedStream: Read buffer must be empty in FlushWrite!");
Debug.Assert(_buffer != null && _bufferSize >= _writePos,
"BufferedStream: Write buffer must be allocated and write position must be in the bounds of the buffer in FlushWrite!");
_stream.Write(_buffer, 0, _writePos);
_writePos = 0;
_stream.Flush();
}