   while (!SD.begin(chipSelect)) {
 
     Serial.println("Card failed, or not present");
-    return;
-
-  }
+    delay(1000);
+
+  }
+
+  // This funny function allows the sd-library to set the correct file created & modified dates for all sd card files.
+  // (See the SDCardDateTimeCallback function defined at the end of this file)
+  SdFile::dateTimeCallback(SDCardDateTimeCallback);
 
   Serial.println("card initialized.");
 


  }

  delay(250);       // Wait a quarter second to continue.

  //Initialize sensors
  sensor.initializeMS_5803(); // Initialize pressure sensor

  sensors.begin();  // Intialize the temperature sensors.
  sensors.setResolution(TEMP_SENSOR_RESOLUTION);  // Set the resolution (accuracy) of the temperature sensors.
  sensors.requestTemperatures(); // on the first pass request all temperatures in a blocking way to start the variables with true data.
  tempA = sensors.getTempCByIndex(0);
  tempB = sensors.getTempCByIndex(1);
  tempC = sensors.getTempCByIndex(2);
  sensors.setWaitForConversion(false);  // Now tell the Dallas Temperature library to not block this script while it's waiting for the temperature mesurement to happen

  ecSerial.begin(9600); // Set baud rate for conductivity circuit.

    pressure_abs = sensor.pressure();

    DateTime now = rtc.now(); //check RTC
    char dateTimeString[40];
    get_date_time_string(dateTimeString, now);

    //output readings to serial
    Serial.print(dateTimeString);
    Serial.print(",");
    Serial.print(pressure_abs);
    Serial.print(",");
    Serial.print(tempA);
    Serial.print(",");
    Serial.print(tempB);
    Serial.print(",");
    Serial.print(tempC);
    Serial.print(",");
    Serial.println(EC);

    //output readings to data file.
    File dataFile = SD.open(datalogFileName, FILE_WRITE);
    if (dataFile) {

      dataFile.print(dateTimeString);
      dataFile.print(",");
      dataFile.print(pressure_abs);
      dataFile.print(",");
      dataFile.print(tempA);
      dataFile.print(",");
      dataFile.print(tempB);
      dataFile.print(",");
      dataFile.print(tempC);
      dataFile.print(",");
      dataFile.println(EC);
      dataFile.close();

