Multiple strings in .txt file after single write

Hey guys. I have a simple data logging method that writes a single string to the micro SD card. When I pull the power from the chip, then open the .txt file on the PC, there is always more than one of the strings present. When I print to the Serial Monitor, it shows up once, but always more than once on the file itself! Any help will be appreciated. Thank you, Arwin.

void saveToSD(){
  File dataFile = SD.open("datalog.txt", FILE_WRITE);

  if (dataFile) {
   
    dataFile.println(sample); //'sample' is the string I want to write
    dataFile.close();
    // print to the serial port too:
   // Serial.println(sample);
  }  
  // if the file isn't open, pop up an error:
  else {
    Serial.println("error opening datalog.txt");
  } 
}

Are you using the same dataFile on the uSD over and over? If so, each time you run that function you are appending (adding to the end of the existing file contents) whatever you write. The "extra" lines you see are probably from the last n times you ran the program.

If that's not it, we'll need to see the rest of the code.

You get a second sd write when you open the serial monitor and get a reset on the sketch.. Take a look at what you see on the card without opening the serial monitor.