How to delete some characters of the .txt file in SD card?

Hi, I'm learning the SD library of arduino in my textbook those days. The SD library provides many functions. For my question, I create a "test.txt" file in my SD card which containing some characters. The code:

#include "SPI.h"
#include "SD.h"

File f;

void setup()
{
Serial.begin(9600);
SD.begin(4);
if(!SD.exists("test.txt"))
{
f = SD.open("test.txt", FILE_WRITE);
f.println("arduino");
f.print("arduino test");
f.close();
}
else
{
f = SD.open("test.txt", FILE_READ);
while(f.peek() != -1)
{
Serial.print((char)f.read());
}
f.close();
}
}

void loop()
{

}

So the test.txt file contains some characters:
arduino
arduino test

I want to delete 'e' and 's' characters in the "test" word above, namely, converting "test" to "tt". How can I write the code? Please don't delete the "test.txt" file in the SD card.
Can anyone help me?
Best regards.

   f = SD.open("test.txt", FILE_READ);
    while(f.peek() != -1)
    {
      if (not <the character you read is one of those specified>) {
        Serial.print((char)f.read());
        ...

aarg:

   f = SD.open("test.txt", FILE_READ);

while(f.peek() != -1)
    {
      if (not ) {
        Serial.print((char)f.read());
        …

Hi, aarg,
Can you give me a detailed code? The tips above are puzzled.
Best regards.

The only way to delete characters from a file is to open the file, and copy the data character by character to a new file while deleting unwanted characters. If you like, delete the first file and rename the new file to replace the old file.

Make your best attempt to write code that carries out this suggestion:

if (not <the character you read is one of those specified>)

and test it. If you continue to have trouble, post again with specific questions.

If you would like someone to write code for you, post on the forum section titled “Gigs and Collaborations”. You may be asked to pay for the help.

jremington:
The only way to delete characters from a file is to open the file, and copy the data character by character to a new file while deleting unwanted characters. If you like, delete the first file and rename the new file to replace the old file.

Thanks a lot. That’s what I needed.
Best regards.

#include "Arduino.h"
#include "SPI.h"
#include "SD.h"

File f;
File f2;

void setup()
{
  Serial.begin(9600);
  SD.begin(4);
  if(SD.exists("test.txt"))
    SD.remove("test.txt");
  f = SD.open("test.txt", FILE_WRITE);
  f.println("arduino");
  f.println("arduino test bb");
  f.close();
  if(SD.exists("test2.txt"))
    SD.remove("test2.txt");
  if(SD.exists("test.txt"))
  {
    f = SD.open("test.txt", FILE_READ);
    f2 = SD.open("test2.txt", FILE_WRITE);
    while(f.peek() != -1)
    {
      if(f.peek() != 'b')
        f2.write(f.read());
      else 
        f.read();
    }
    f.close();
    f2.close();
    f2 = SD.open("test2.txt", FILE_READ);
    while(f2.peek() != -1)
    {
      Serial.print((char)f2.read());
    }
    f2.close();
    Serial.println();
  }
  if(SD.exists("test.txt"))
    SD.remove("test.txt");
  if(SD.exists("test2.txt"))
  {
    f = SD.open("test.txt", FILE_WRITE);
    f2 = SD.open("test2.txt", FILE_READ);
    while(f2.peek() != -1)
    {
        f.write(f2.read());
    }
    f.close();
    f2.close();
    SD.remove("test2.txt");
    f = SD.open("test.txt", FILE_READ);
    while(f.peek() != -1)
    {
      Serial.print((char)f.read());
    }
    f.close();
    Serial.println();
  }  
}

void loop()
{

}