Using the SD card AND the Ethernet on sheild causes issues

If you want to use multiple SPI devices. Disable all before starting any of them.

In setup, use this :
// disable SD SPI
pinMode(4,OUTPUT);
digitlWrite (4,HIGH);

// disable w5100 SPI
pinMode(10,OUTPUT);
digitalWrite(10,HIGH);

// rest of setup code