Yes thank you. This is a classic mistake that many first time programmers make. Years ago somebody was comparing the speed of C++ over VBScript/IIS over Java for writing Web pages back to a browser. They too came to a similar conclusion - and also made the same mistake.
When writing to disk - the data is written once. The algorithm for in memory is not doing the same thing. It is allocating a new buffer - copying all data to said new buffer - and finally adding data to the end. If one compared the I/O of the two program executions the "in-memory" version would have many times MORE I/O.
Doing this:
Loop N.{ x = x + newValue}
Write(x)
Will always be slower than
Loop N.{ Write(newValue) }
In C# and I think Java - there is an object called StringBuffer - and is intended for this kind of workload. The first thing I learned in data structures class was how to expand buffers using different algorithms and pro/con of each (heap design for instance, buddy system).
Plus - O(n) is not created equal. :-P