File handles are flushed when they are closed, and they are closed when the program ends. This happens even when
are called. It looks like your program is crashing in a manner serious enough to prevent this, since you have more data in the file when you turn off buffering. At least that's how I interpret this. Good luck!