SD CARD Create File and then Read Directory Problem

Use this to locate files and try to remove stuff which you don't need

File dataFile;
Sd2Card card;
SdVolume volume;
SdFile root;

void setup()
{
  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  pinMode(10, OUTPUT);
  
  if (!card.init(SPI_HALF_SPEED, 4)) {
    Serial.println("initialization failed. Things to check:");
    Serial.println("* is a card is inserted?");
    Serial.println("* Is your wiring correct?");
    Serial.println("* did you change the chipSelect pin to match your shield or module?");
    return;
  } else {
   Serial.println("Wiring is correct and a card is present."); 
  }
  
  if (!volume.init(card)) {
    Serial.println("Could not find FAT16/FAT32 partition.\nMake sure you've formatted the card");
    return;
  }

  if (!SD.begin(4)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");
  
  dataFile = SD.open("examlpe.CSV", FILE_WRITE); //if I comment this out then the list files works
  if (dataFile) {
    Serial.print(F("Writing to test.txt..."));
    dataFile.println("NOW this FILE CREATED");
    dataFile.close();
    Serial.println(F("done."));
  }
  
  
 
   Serial.println("Created File: examlpe.CSV");
     
  // re-open the file for reading:
  dataFile = SD.open("examlpe.CSV");
  if (dataFile) {
    Serial.println("examlpe.CSV:");
    
    // read from the file until there's nothing else in it:
    while (dataFile.available()) {
    	Serial.write(dataFile.read());
    }
    // close the file:
    dataFile.close();
  } else {
  	// if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }
}


void loop()
{
  Serial.println("\nFiles found on the card (name, date and size in bytes): ");
  root.openRoot(volume);
  // list all files in the card with date and size
  root.ls(LS_R | LS_DATE | LS_SIZE);
}

cheers