 void log_to_sd(float temperature_f, float humidity, float heat_index, uint32_t current_time) {
   Serial.println("writing to SD card...");
   
-  Fat16 data_file;
-  
-  if (data_file.open("data.csv", O_CREAT | O_APPEND | O_WRITE)) {
+  File data_file;
+  
+  if (data_file = SD.open("data.csv", FILE_WRITE)) {
     data_file.print(current_time); data_file.print(",");
     data_file.print(temperature_f); data_file.print(",");
     data_file.print(humidity); data_file.print(",");


  uint32_t current_time = rtc.now().unixtime();
  uint32_t last_reading_time = get_last_reading_time();
  
  Serial.print("time since last reading: ");
  Serial.print(current_time - last_reading_time);
  Serial.print(", current_time: ");
  Serial.print(current_time);
  Serial.print(", last_reading_time: ");

        }
      }
      if (timestamp_input) break;
      watchdog_feed();
      delay(1000);
    }

