public override void Close() { FlushBuffer(); FlushEncoder(); // Future calls to Close or Flush shouldn't write to Stream or Writer writeToNull = true; if ( stream != null ) { stream.Flush(); if ( closeOutput ) { stream.Close(); } stream = null; } }