If the new document is longer than the old one, the file (and stream) will automatically expand.
If not, you can truncate the file by calling stream.SetLength()
.
You would want to set it to stream.Position
, which indicates how many bytes have been written so far.