Can't list files after writting on a file

I want to list the files of my SD card many times, but after I open a file and write on it I can't list the files again. I think that the program wants to list from the position of my last file and that's why I dont see anything. Any suggestions?

#include <SPI.h>
#include <SD.h>
File root;
void setup()
{
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
  Serial.print("Initializing SD card...");

  if (!SD.begin(4)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");
}

void loop()
{

  root = SD.open("/");
  printDirectory(root, 0);

  File dataFile = SD.open("012011.TXT", FILE_WRITE);
dataFile.close();
  Serial.println("done!");
  delay (5000);
  // nothing happens after setup finishes.
}

void printDirectory(File dir, int numTabs) {
   while(true) {
     
     File entry =  dir.openNextFile();
     if (! entry) {
       // no more files
       break;
     }
     for (uint8_t i=0; i<numTabs; i++) {
       Serial.print('\t');
     }
     Serial.print(entry.name());
     if (entry.isDirectory()) {
       Serial.println("/");
       printDirectory(entry, numTabs+1);
     } else {
       // files have sizes, directories do not
       Serial.print("\t\t");
       Serial.println(entry.size(), DEC);
     }
     entry.close();
   }
}

Same thing happened to me. Its a "bug" if you do a root.seek(0); after the root open then it will work. I was "removing" files, removed the last file and could not list again. Removed a file in the middle and the next file was first in the list when i called list directory. Must be that the code does not reset a pointer to the directory block when an open to "root" is called.