Don't replace on disk if the file has changed since we searched it
Add test for gracefully handling write failure