File.close - how safe?

Hello,
New here, but not so much to Arduino.

I have a data logging (every 10-seconds) sketch using an SD card. It has me wondering what happens if the power is dropped before it finishes a write and never gets to the file.closed.

Pseudo code...
1: Timer = 10 seconds
2: ..Open file
3: ....write data
4: ....write data
5: ..close file

What happens to the data file is the power fails after line 3 and before line 5?

Will it trash the entire file or just not save the last data?

At the minimum, you lose the unwritten data.

At the minimum, you lose the unwritten data.

At a maximum, too.

OK, thanks, I had tried pulling the plug quite a few times to simulate power out and the file seemed to stay intact. Same when I increased the sample time to 30-seconds for testing and pulling the plug.

There was no way I could tell if the last data was dumped or not in real life, but I can live with losing that last lump of data.