SD ReadWrite example writes too often

An Arduino sketch starts when you power up or load a sketch. The Arduino is reset when you open the serial monitor. This means the sketch runs several times, not just once.

Change this:

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

To this:

 Serial.println("Type any character");
 while (Serial.read() < 0);
 Serial.print("Initializing SD card...");

This will prevent writing to the SD before the serial monitor is running.

Then run the sketch and type a character when this message prints.

Type any character