atomic state file write