SD Card from an Ethernet Shield works somtimes and stop working sometimes

Hello,

I am working with the Mega ADK and I have the Arduino Ethernet Shield connected with an SD card.

I have made the SD card work writing files, deleting, creating directories. But unexpectedly stop working sometimes.
I have not identified how it just simple start working again. I reset everything, reformat the SD, etc. But no sure what is the issue.
May be could stop working when i just simple try to read the SD card directly in the computer (Windows 7) for checking the files (but not sure).

Saying

Initializing SD card…SD Initialization failed!

I have change PIN 10, PIN 53 and used the SD.begin(4).
Only tested PIN 10 and it worked a while, tested with both at the same time 10 and 53 and worked a while.

I am just putting a piece of code of the complete program, just the same example adding the digitalWrite(10,HIGH) or 53. To deactivate the Ethernet Card.
I am not using the Ethernet card yet, only the SD
Although in the code you see 10 and 53 at the same i have tried all combination, only one, both, only the last one. Thanks

Here is the code

#include <SD.h>

File myFile;

void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}

Serial.print(“Initializing SD card…”);
// On the Ethernet Shield, CS is pin 4. It’s set as an output by default. Note that even if it’s not used as the CS pin, the hardware SS pin (10 on most Arduino boards, 53 on the Mega) must be left as an output or the SD library functions will not work.

pinMode(53, OUTPUT);
digitalWrite(53,HIGH); // need for the pull up resistor

pinMode(10, OUTPUT);
digitalWrite(10,HIGH);

if (!SD.begin(4)) {
Serial.println(“SD Initialization failed!”);
return;
}
Serial.println(“SD Initialization done.”);

if(!(SD.exists("/AWE"))) //always from the root
SD.mkdir("/AWE");

// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
myFile = SD.open("/AWE/test.txt", FILE_WRITE);

// if the file opened okay, write to it:
if (myFile) {
Serial.print(“Writing to test.txt…”);
myFile.println(“testing 1, 2, 3.”);
// close the file:
myFile.close();
Serial.println(“done.”);
} else {
// if the file didn’t open, print an error:
Serial.println(“error opening test.txt”);
}

// re-open the file for reading:
myFile = SD.open("/AWE/test.txt");
if (myFile) {
Serial.println("/AWE/test.txt:");

// read from the file until there’s nothing else in it:
while (myFile.available()) {
Serial.write(myFile.read());
}
// close the file:
myFile.close();
} else {
// if the file didn’t open, print an error:
Serial.println(“error opening test.txt”);
}
}

void loop()
{
// nothing happens after setup
}