For robustness this should somehow use `O_CREAT | O_EXCL` to be on the safe side, and maybe `unlink` the *.tmp* file (with a catch in case it doesn't exist).