I know this might seem silly, but why does the following code only work if I Close() the file? If I don\'t close the file, the entire stream is not written.
Operating system cache write to block devices to enable the OS to have better performance. You force a write by flushing the buffer after a write of setting the streamwriter to autoflush.