Although we are (usually) careful about using transactions when working with databases, too often we assume that data writes to a file will always succeed. This is not always the case, and especially these days when chunks of XML are being written to files it is especially important to verify that the writes to the files are atomic operations. That is, that either everything you intend to be written to the file is actually written, or nothing is. There should be no case where data is cut off.
From Adi Oltean's excellent blog comes this post about how to do atomic writes to a file. I was interested to learn that some of the assumptions that I held about files (and especially about how the StreamWriter class works) are wrong. So thanks to Adi for the clarification.