Can not write files to 2 micro SD card modules connected to a Mega.

I am trying to write a text file ("test.txt") to each of the micro SD card modules. But only 1 module has the test.txt file on it the other micro sd card is blank. I have wired it as follows:

pin 50 to both MISO.
pin 51 to both MOSI.
pin 52 to both SCK.
pin 9 to CS on one micro SD card.
pin 10 to cs on one micro SD card.
3.3v to both VCC.
Ground to both GND.

Here is the code...

// Libraries to drive the SD Card. ******************************
#include <SD.h>

/* The SD card communicates over pins for the Arduino Mega:
MOSI - Pin 51
MISO - Pin 50
Clock - Pin 52
Chip Select - pin 53

Yellow LED goes on during a read operation.
Red LED goes on during a write operation.

Use '(char *)filename.c_str()' to pass a string variable to concatinate the file name.
Use 'filename.c_str()' to pass a variable file name to the FILE.open(fn,option) command.
Make sure to disconnect the power to the SD card shield prior to removing
the chip.
*/

int baudrate = 9600; //set the baud rate.

String filename; //Store file name.
String root = "/";
int var; //Case statement variable.
int countMakeDirectory = 0;//Test.
int countMakeFile = 0;//Test.
int countListDirectory = 0;//Test.
int loopCounter = 0;//Test.
int rootCounter = 1;//test.
int CSpinRequired = 53; //Chip Select pin required by SD library.
int CSpin1 = 10; //Chip Select pin 2.
int CSpin2 = 9; //Chip Select pin 3.
File myFile; //File to open.

//setup *************************************************************************
void setup()
{
Serial.begin(baudrate); // Start serial communication.
pinMode(CSpinRequired, OUTPUT);//Required by the SD library.
pinMode(CSpin1, OUTPUT);//Used as Chip Select.
pinMode(CSpin2, OUTPUT);//Used as Chip Select.

root = "/"; //Set the root directory.

}//End setup.

//loop *********************************************************************************
void loop()
{
loopCounter = loopCounter + 1;

Serial.println();
Serial.print(F("Loop Counter--> "));
Serial.println(loopCounter);

var= random(1,4); //Test random CASE option.
filename = ""; //test: reset filename. line 200

if ( (loopCounter % 2) == 0) { //If loopCounter is Even.

Serial.println(F("OLD CARD"));//Use this option to reduce SRAM memory useage and increase 32K main memory useage.
digitalWrite(CSpin1, LOW);//Set to HIGH to Disable. Set to LOW to Enable.
delay(500);
digitalWrite(CSpin2, HIGH);//Set to HIGH to Disable. Set to LOW to Enable.
delay(500);
SD.begin(CSpinRequired);
delay(500);

}//End if.

else { //If loopCounter is Odd.

Serial.println(F("NEW CARD"));//Use this option to reduce SRAM memory useage and increase 32K main memory useage.
digitalWrite(CSpin1, HIGH);//Set to HIGH to Disable. Set to LOW to Enable.
delay(500);
digitalWrite(CSpin2, LOW);//Set to HIGH to Disable. Set to LOW to Enable.
delay(500);
SD.begin(CSpinRequired);
delay(500);

}//End else.

switch(var){

case 1:
Serial.println(F("List Directory..."));
ListDirectory();//Call function.
countListDirectory = countListDirectory + 1;
break;

case 2:
Serial.println(F("Make File..."));
MakeFile(); //Call function.
countMakeFile = countMakeFile + 1;
break;

case 3:
Serial.println(F("Make Directory..."));
MakeDirectory(); //Call function.
countMakeDirectory = countMakeDirectory + 1;
break;

} //End case statement.

if( loopCounter >= 10){

Serial.println(F("****************************************"));

Serial.print(F("Total List Directory..."));
Serial.println(countListDirectory);

Serial.print(F("Total Make File..."));
Serial.println(countMakeFile);

Serial.print(F("Total Make Directory..."));
Serial.println(countMakeDirectory);

while(true); //Test.Stop program.
} //End if.

} //End loop.

//MakeDirectory **************************************************
void MakeDirectory(){

Serial.println(F("(1)Make the directory...")); //debug.

//generate a random file name.Remove.
int i = random(65,90);//test.
filename = String((char) i);//test.
Serial.print(F("(2)Directory: "));//test.

filename = root + filename;
Serial.println(filename);//test.

SD.mkdir("/DIR1/");
delay(500); //Wait for SD card to complete.
myFile.close(); //Write the file to the SD card.
delay(500); //Wait for SD card to complete.

} //End MakeDirectory function.

//MakeFile **********************************************************
void MakeFile(){

Serial.println(F("(1)Make a file...")); //debug.

//generate a random file name.Remove.
int i = random(65,90);//test.Create a chara A to Z.
filename = root + String((char) i) + ".txt";//test.
Serial.print(F("(2)"));//test.
Serial.println(filename);//test.

myFile = SD.open("FILE.TXT", FILE_WRITE);
delay(500);//Wait for file to open.

myFile.close(); //Close the file and save it to the SD card.
delay(500);//Wait for file to close.

} //end MakeFile function.

//ListDirectory **************************************************
void ListDirectory(){

myFile = SD.open("/"); //Root directory.
delay(200);//Wait for myFile to open.
PrintDirectory(myFile, 0);
myFile.close();//Close the myFile.
delay(200);//Wait for file to close.

}//end ListDirectory function.

// PrintDirectory **************************************************
// This code is from the arduino library SD Listfiles ( https://www.arduino.cc/en/Tutorial/listfiles ).
// The code does not work correctly. The last entrys in a subdirectory does not display.

void PrintDirectory(File dir, int numTabs) {
dir.seek(0); // Add seek!!!

while (true) {

File entry = dir.openNextFile();
if (! entry) {
dir.rewindDirectory();
break;
} //End if.

for (uint8_t i = 0; i < numTabs; i++) {
Serial.print('\t');
} //End for.

Serial.print(entry.name());
if (entry.isDirectory()) {
Serial.println("/");
PrintDirectory(entry, numTabs + 1);
} //End if.

else
{
// files have sizes, directories do not
Serial.print("\t\t");
Serial.println(entry.size(), DEC);
} //End else

entry.close(); //Write the file to the disk.

} //End while.

} //End PrintDirectory function.

Can anyone help???
Thx.

Please edit your post to add code tags: ("</>") button.