private void ThrowIfClosed() { if (tempStream == null) throw new Exception("The writer is closed."); } }