Example sketch writing to sd twice.

I loaded the example file readwrite.ino from the included files in the arduino ide example directory.
When I run the sketch it writes to the sd 2 or 3 lines in the file of the same text.
I've looked over and over the example sketch readwrite.ino, and can not figure out why it is writing more than 1 line in the file . I checked the file on a laptop, and it is written more than once.
Any ideas ?

It only writes once, but it appends a new line each time it runs. So it's easy to think it has written more than once, especially since it will run as soon as you download the code, before you even turn on the serial monitor.

One way to avoid this sort of confusion is to require a button press or keyboard entry before doing anything. Try putting this in setup():

Serial.print("Enter any key:");
while (!Serial.available()) {}

it will run as soon as you download the code, before you even turn on the serial monitor.

When you open the serial monitor is causes the program to reset and run a second time. One way to see this is download the example program, pull the card, and read it in your computer before opening the serial monitor.