tmp file atomic write