Sd card printout stops after 10 times

I'm using the DFRobot Interface sd card shield(CS pin 10) and trying to print out data from 3 sensor(A0-A2) to 3 different .txt documents.
And the problem is this, after exactly 10 times running the main loop, it can't open the files anymore and starts giving me the error code:
I've been using most of the code from the example for the SD Datalogger with a few tweaks here and there for my purposes:

#include <SD.h>

const int chipSelect = 10;

void setup()
{
  Serial.begin(9600);
   while (!Serial) {;
  }


  Serial.print("Initializing SD card...");
  pinMode(10, OUTPUT);
  if (!SD.begin(chipSelect)) {
    Serial.println("Card failed, or not present");
    return;
  }
  Serial.println("card initialized.");
}

void loop()
{
  delay(1000);
  float sensor = analogRead(A0)*(5.0/1023.0);
  File dataFile = SD.open("datalogv.txt", FILE_WRITE);
  if (dataFile) {
    dataFile.println(sensor);
    dataFile.close();
    Serial.println(sensor);
  }  
  else {
    Serial.println("error opening datalogv.txt");
    }
    
  float sensor1 = analogRead(A1)*(5.0/1023.0);
  File dataFile1 = SD.open("dataloga.txt", FILE_WRITE);
  if (dataFile1) {
    dataFile.println(sensor1);
    dataFile.close();
    Serial.println(sensor1);
  }  
  else {
    Serial.println("error opening dataloga.txt");
    }
    
  float sensor2 = analogRead(A2)*(5.0/1023.0);
  File dataFile2 = SD.open("datalogt.txt", FILE_WRITE);
  if (dataFile2) {
    dataFile.println(sensor2);
    dataFile.close();
    Serial.println(sensor2);
  }  
  else {
    Serial.println("error opening datalogt.txt");
  } 
}

To summarise my question, why does it start giving me the: "error opening datalogx.txt" (x for a,t,v) after 10 times?

For anybody with the same problem, I found out what is the origin of the error.
Since this was my first time working with files I accidentally deleted the file.close() function.
After about 30 files being opened, it can't open anymore.

You are opening three different files, writing to one file, and closing one file. Your 2nd and 3rd attempts to write to the one file fail because the file isn't open.

Put the logging stuff in a function that you pass the sensor pin and file name to. That way, the file you open is the file that you write to and the file that you close.