If you're warry about lost of the file(s), you can:
- before deleting of
A.txt
(say) on startup create it's copyA.tmp
and after delete. - on close, create new files and delete all
tmp
file(s) present in directory.
In this way, if something went wrong during program run, when program starts again, it will find tmp
last created, so can reconstruct information (if need) from them and continue program cycle.