delete first line from txt file from sd card...

I am folllowing this link:How to delete first line from a text file - Storage - Arduino Forum
this is my first line in text file in sd card:0testing 1, 2, 3.
i want to delete this line..

i have tried following code as chucktodd said:

/*
  SD card read/write

 This example shows how to read and write data to and from an SD card file
 The circuit:
 * SD card attached to SPI bus as follows:
 ** MOSI - pin 11
 ** MISO - pin 12
 ** CLK - pin 13
 ** CS - pin 4 (for MKRZero SD: SDCARD_SS_PIN)

 created   Nov 2010
 by David A. Mellis
 modified 9 Apr 2012
 by Tom Igoe

 This example code is in the public domain.

 */

#include <SPI.h>
#include <SD.h>

#define LINELEN 19  // length of line including EOL characters, I assume crlf  0x0D 0x0A
  // so the line is actually 32 text characters plus 2 end of line characters for 34 total.

File myFile;

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }


  Serial.print("Initializing SD card...");

  if (!SD.begin(10)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");

  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
 myFile = SD.open("testA.txt");

  // if the file opened okay, write to it:
  if (myFile) {
  uint32_t line=1;
      uint32_t S= (line-1)*LINELEN;
      myFile.seek(S);  //position the 'file pointer' to where I want to start over-writing.

     char ch[20]; // got to remember c++ strings need a \0 to mark the end.

    // build the 'delete line'
for(uint8_t i=0;i<17;i++) ch[i]=' ';
ch[17]='\r'; //  (cr)
ch[18]='\n'; // newline (lf)
ch[19]='\0'; // end of string marker;

// over write (delete) the existing data
  myFile.print(ch); // all marked as deleted! yea

    myFile.close();
    Serial.println("done.");
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }

  // re-open the file for reading:
  myFile = SD.open("testA.txt");
  if (myFile) {
    Serial.println("testA.txt:");

    // read from the file until there's nothing else in it:
    while (myFile.available()) {
      Serial.write(myFile.read());
    }
    // close the file:
    myFile.close();
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }
}

void loop() {
  // nothing happens after setup
}

17 characters are there in that line ...but it wont delete the line .. :confused:

now i can delete first line:
i removed spaces between characters;;;;

/*
  SD card read/write

 This example shows how to read and write data to and from an SD card file
 The circuit:
 * SD card attached to SPI bus as follows:
 ** MOSI - pin 11
 ** MISO - pin 12
 ** CLK - pin 13
 ** CS - pin 4 (for MKRZero SD: SDCARD_SS_PIN)

 created   Nov 2010
 by David A. Mellis
 modified 9 Apr 2012
 by Tom Igoe

 This example code is in the public domain.

 */

#include <SPI.h>
#include <SD.h>

#define LINELEN 15  // length of line including EOL characters, I assume crlf  0x0D 0x0A
  // so the line is actually 32 text characters plus 2 end of line characters for 34 total.

static uint32_t line=1;
File myFile;

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }


  Serial.print("Initializing SD card...");

  if (!SD.begin(10)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");

  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
 myFile = SD.open("testC.txt",FILE_WRITE);

  // if the file opened okay, write to it:
  if (myFile) {
  
uint32_t S= (line-1)*LINELEN;

myFile.seek(S);  //position the 'file pointer' to where I want to start over-writing.

char ch[15]; // got to remember c++ strings need a \0 to mark the end.

// build the 'delete line'
for(uint8_t i=0;i<13;i++) ch[i]=' ';
ch[13]='\r'; //  (cr)
ch[14]='\n'; // newline (lf)
ch[15]='\0'; // end of string marker;

// over write (delete) the existing data
myFile.print(ch); // all marked as deleted! yea
 /*  Serial.print("Writing to test.txt...");
    for(int i=0;i<=10;i++){
    myFile.print(i);
    myFile.println("testing1,2,3");
    }*/
    // close the file:
    myFile.close();
    Serial.println("done.");
  
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }

  // re-open the file for reading:
  myFile = SD.open("testC.txt");
  if (myFile) {
    Serial.println("testA.txt:");

    // read from the file until there's nothing else in it:
    while (myFile.available()) {
      Serial.write(myFile.read());
    }
    // close the file:
    myFile.close();
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }
}

void loop() {
  // nothing happens after setup
}

but i want to update second line as a first line ..
means whenever loop executes it should delete first line..

That code is a mess. Do fix your indentation (ctrl-T in the IDE).

Probably easiest: read the file line by line, write it out to a new file, skipping the first line.

actually i am having face detection machine..whenever face detected data to be stored in sd card in text file ..and sent that text file data through gprs tcp /ip to the server tcp port...
i have got success in following things:
1: getting wiegand out ID from FACE detection machine ...
2:used rtc ds1307 to get time and date
3:ID+DATE+TIME string is stored in SD card text file Line by Line
4:reading first line from text file from sd card after every 15 Minutes and send it through gprs tcpip
5:got success in sending first line to tcp port
6:and also compared the response of gprs module with "OK" When AT+CIPSEND succeeded..
7:store that successfully sent string to another text file

i have stuck in this:
when i successfully sent (first line of text file)to tcp port and store that string in another text file

:in next iteration want to send next line of text file(2nd line)..and so on
means i want to send whole text line by line to tcp port..

what could be the possible solution?

Thank You...