I have a timer based application that might write a short line to a file every 8 hours. The file doesn't stay open for the 8 hour duration, I just open it, write and close it. If it helps, I open the file for writing only, not appending, so the previous data in it doesn't need to be saved.
What would happen if the user closes the application through task manager while the file is open for writing? Can I make the file writing operation atomic? Or can I at least prevent the application from closing if the file is open?