Sqlite is much better than raw files to keep data intact on power failures, and be sure to study the options carefully
If you truly need to use files you can take other steps such as mv the old file to .bck before mv the new file, but I really think you want sqlite