I've been having an unusual problem writing to SD cards using the sparkfun microSD shield and a 4gb card. Bascially, the arduino reports that the file opens and closes ok, but the data does not actually appear in the resulting file. The code below reproduces the error very reliably, however the exact amount of data that is written to the file varies.

This code should produce a file that contains integers that increment by 2 indefinitely, one number per line:

If you mean this shield, then you may be running out of power.https://www.sparkfun.com/products/9802This card uses the 3.3v output of the Uno. That is max 50ma supply. The SanDisk cards require around 100ma to read and write. Here is another thread covering this.http://arduino.cc/forum/index.php/topic,132303.0.html

The Sparkfun microsSD shield uses pin 8 for chip select. Sometimes it will sort of work using pin 10.

Quote

CS pin is broken out to Arduino's D8 pin. If you decide to use one of the many open source FAT libraries (like FAT16 or SDFat) make sure to change the code to reflect the location of the CS pin. Most libraries assume the CS pin is connected to D10; this will have to be changed to D8.