ensure tlfs are synced before renaming them to their destination

I like the `with_temp_file` idea which also performs renaming.