add atomic file write example with temporary files