It would be nicer to write the new content first, and only then truncate. This way even if the worst happens, there is less data loss.
It would be nicer to write the new content first, and only then truncate. This way even if the worst happens, there is less data loss.