Don't try to assert anything because this whole thing is supposedly JRE 1.4-compatible.
Try to write files atomically.