user4527: I have a datafile, datalog.txt I can open, read and write cool. What is the best way to delete all the file contents?
Should I try rewriting the SD card file with NULL data?
I have been reading the "SD.h" header file. I see a flush() and truncate() function should I use one of these?
or maybe I should just close  and reopen the file, and overwrite the data. But I'm concerned that this might lead to some miss representations if the old data is not completely removed.
I am using a teensy 4.1 with built_in SD card.

user37622: To remove a file use SD.remove("datalog.txt");
SD library's FILE_WRITE is O_READ | O_WRITE | O_CREAT | O_APPEND so it would append at the end of the existing file.
to start with an empty file: File file = FS.open("datalog.txt", O_READ | O_WRITE | O_CREAT);
EDIT: opening the file with O_READ | O_WRITE | O_CREAT doesn't clear the content of the file, only starts to overwrite it from the beginning.

4527: <p>I have a datafile, datalog.txt I can open, read and write cool. What is the best way to delete all the file contents?
Should I try rewriting the SD card file with NULL data?
I have been reading the &quot;SD.h&quot; header file. I see a flush() and truncate() function should I use one of these?</p>
<p>or maybe I should just close  and reopen the file, and overwrite the data. But I'm concerned that this might lead to some miss representations if the old data is not completely removed.</p>
<p>I am using a teensy 4.1 with built_in SD card.</p>
 37622: <p>To remove a file use <code>SD.remove(&quot;datalog.txt&quot;);</code></p>
<p>SD library's <code>FILE_WRITE</code> is <code>O_READ | O_WRITE | O_CREAT | O_APPEND</code> so it would append at the end of the existing file.</p>
<p><del>to start with an empty file: File file = FS.open(&quot;datalog.txt&quot;, O_READ | O_WRITE | O_CREAT);</del></p>
<p>EDIT: opening the file with O_READ | O_WRITE | O_CREAT doesn't clear the content of the file, only starts to overwrite it from the beginning.</p>
