Problems writing to sd card on datalogger

I’m new to Arduino, this is my first post here.
My setup is an Arduino Mega 2566, an Adafruit Data Logger Shield, a Grove Mega Shield, and an Adafruit 16x2 lcd display
I have four One Wire temperature sensors, three DHT22 sensors, a Grove Electricity sensor, and a relay to control a pump.

The board will control a pump that circulates a glycol loop underground to a coil connected to a heat recovery ventilator and either preheat or cool incoming air to a house.

Various temperature sensors control the operation of the system. The three DHT22 sensors are just placed in points of interest and are merely displayed on the screen and then written to the datalogger.

I’m having an issue with writing the temperature and humidity data to the sd card. It seems to continually write the headers to the file, but never the data points. I can’t figure out what is going wrong.

This code is drawn from another project, I’ve been modifying it for my use.

Header portion of code (this seems to be working)

//  set up SD card  
  Serial.println();
  delay(2000);
  lcd.clear();
  Serial.print(F("Init SD card..."));
  lcd.clear();
  lcd.print("Init SD Card...");
  if (!SD.begin(ssPin)) { // SS for SD card
    Serial.println(F(" init failed!"));
    lcd.setCursor(0,1);
    lcd.print("init failed");
  // do forever...   HANG!
    while (true);
  }
  Serial.println(F("initialization done."));
  lcd.setCursor(0,1);
  lcd.print(F("initalized"));
  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
  myLogFile = SD.open("KYLE.CSV", FILE_WRITE);
  // if the file opened okay, write to it:
  if (myLogFile) {
    Serial.println(F("Writing to Logfile..."));
  } else {
    // if the file didn't open, print an error:
    Serial.println(F("* error opening LogFile"));
    delay(2000);
    lcd.clear();
    lcd.print(F("Error opening"));
    lcd.setCursor(0,1);
    lcd.print(F("logfile"));
  // do forever... HANG!
    while (true);
  }
  
  // create csv header
  Serial.print(F("T"));
  myLogFile.print(F("T"));
  Serial.print(F(", I "));
  myLogFile.print(F(", I "));
  for (sensor=0;sensor<MAX_SENSORS;sensor++)
  { 
    Serial.print(F(", "));
    myLogFile.print(F(", "));
    Serial.print(senName[sensor]);
    myLogFile.print(senName[sensor]);
  }
  // DHT22 data
    
  Serial.print(F(", "));
  myLogFile.print(F(", "));
  Serial.print(dhtNames[0]);
  myLogFile.print(dhtNames[0]);

  Serial.print(F(", "));
  myLogFile.print(F(", "));
  Serial.print(dhtNames[1]);
  myLogFile.print(dhtNames[1]);

  Serial.print(F(", "));
  myLogFile.print(F(", "));
  Serial.print(dhtNames[2]);
  myLogFile.print(dhtNames[2]);

  Serial.print(F(", "));
  myLogFile.print(F(", "));
  Serial.print(dhtNames[3]);
  myLogFile.print(dhtNames[3]);

  Serial.print(F(", "));
  myLogFile.print(F(", "));
  Serial.print(dhtNames[4]);
  myLogFile.print(dhtNames[4]);

  Serial.print(F(", "));
  myLogFile.print(F(", "));
  Serial.print(dhtNames[5]);
  myLogFile.print(dhtNames[5]);
  // end DHT22 data
  Serial.print(F(", "));
  myLogFile.print(F(", "));
  Serial.print(F(" sysOpMode"));
  Serial.println(F(", End"));
  myLogFile.println(F(", END"));
  myLogFile.flush();
  myLogFile.close();

And the code for the datapoints

 if (runTime > (lastLogTimeMins + logintervalmins)) {
  //
  // create records for database
  //
    myLogFile = SD.open("KYLE.CSV", FILE_WRITE);
    myLogFile.print(thisTime);
    myLogFile.print(F(", "));
    myLogFile.print(runTime, DEC);
    Serial.print(runTime, DEC);
    for (sensor=0;sensor<MAX_SENSORS;sensor++)
    { 
      myLogFile.print(F(", "));
      myLogFile.print(currentTemp[sensor],2);
    }
    // add DHT22 data
    myLogFile.print(F(", "));
    myLogFile.print(t1,2);
    myLogFile.print(F(", "));
    myLogFile.print(h1,2);
    myLogFile.print(F(", "));
    myLogFile.print(t2,2);
    myLogFile.print(F(", "));
    myLogFile.print(h2,2);
    myLogFile.print(F(", "));
    myLogFile.print(t3,2);
    myLogFile.print(F(", "));
    myLogFile.print(h3,2);
    // end DHT22 data
    myLogFile.print(F(", "));
    myLogFile.print(sysOpMode, DEC);
    myLogFile.println(F(", END"));
    myLogFile.flush();
    myLogFile.close();

    lastLogTimeMins = runTime;
  }

Attached is the full code. Any help would be appreciated.

KylemorePassivePreHeaterSketchbookV8c.ino (67.4 KB)