Advice on using an SD card as data storage

Hi, I'm currently making a project where by I need to record between 10 and 30 integer values. I need to record these to an SD card. I'm currently using the UTFT_tinyFAT and tinyFAT libraries, as the SD card reader I have is built into a Touch screen display unit. The problem I'm having is that I cant see any way to write to a file and over write what is already there using this library, I can see how to write a new line using file.WriteLn(text), but basically I want to replace the content of the file every time the data values change, as I have no need to record the change, just the current values.

To give a bit of background my project will record changes in values, in response to input on the touchscreen and record them to the SD card. I want the project to record these values everyday, and I have an RTC and was thinking of creating a new file on the SD card each midnight, and then write the current values to that file, then during the next 24 hours the values within the file would be updated whenever they need to, and at the next midnight a new file would be created etc. etc.

Can anyone give me some advice on the best way to do this. The only thing I have come up with so far is to delete the file and create a new one everytime the values change, but this doesnt seem the best way, as if power was cut at the wrong time it could lead to the file being deleted and the device powering off before the new file is written. Also it would be better if I could just read and write an array of integers, instead of having to turn everything into Strings and back again!

Hopefully this makes sence!

I'm currently using the UTFT_tinyFAT and tinyFAT libraries

That you got from where?

Typically, the arguments to the File::open() method define what happens if the file to be opened does not exist (it can be created or that can be an error) or does exist (open for overwrite or open for append).

What argument(s) are you using?

Also it would be better if I could just read and write an array of integers, instead of having to turn everything into Strings and back again!

You should be avoiding Strings.

The file does not care if it contains binary data or ascii data. Apparently, you do, so stop writing ascii data to the file. Write binary data, instead. The highByte() and lowByte() macros could be useful.