 
 void newFile(){
 
-    // File format should be: UNIXTIME_yyyy-mm-ddThhmmss
-    // For example: 1506907892_2017-10-02T193101.csv
-    // which is: 2017/Oct/02 7:39:01pm
-    /*
-    int unix   = now.unixtime();
+    // Fat32 limits file names to 8 characters plus a 3 character extension
+    // UNIX time is 10 characters long so we truncate off the first two characters to 
+    // form the file name. 
+
+    DateTime now = RTC.now();
+    unsigned long unix   = now.unixtime();
     int year   = now.year();
     int month  = now.month();
     int day    = now.day();
     int hour   = now.hour();
     int minute = now.minute();
     int second = now.second();
-    */
-    unsigned long unix   = 1506907891;
-    int year   = 2017;
-    int month  = 10;
-    int day    = 2;
-    int hour   = 19;
-    int minute = 31;
-    int second = 4;
 
     char buff[580];
     char *header = buff;

float STREAM_INTERVAL = 1;

// define the Real Time Clock object
RTC_DS1307 RTC; 

// for the data logging shield, we use digital pin 10 for the SD cs line
const int chipSelect = 0;

// the logging file
File TGC_logfile;


    float *voltages, *amps, *temps; //create pointers to point at data

    voltages = readVoltage();
    amps = readAmp();
    temps = readTemp();
    readTime(time);
    //printArray(voltages, 4);
    //printArray(amps, 4);
    //printArray(temps, 3);
    //serialOut(time);
    serialOut("Old filename:");
    serialOut(filename);
    newFile();
    serialOut("New filename:");
    serialOut(filename);
    delay(2000);
    //sleep();
    return;
}

void printDirectory(File dir, int numTabs){
    //reccursively print all files and directories inside 'dir'. Use "/" for root
while (true) {
    File entry =  dir.openNextFile();
    if (! entry) {
      // no more files
      break;
    }
    for (int 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();
  }
}

void setup() {

    Serial.begin(9600);
    serialOut("");

    // Real Time Clock (RTC) setup
    if (! RTC.begin()) {
        Serial.println("Couldn't find RTC");
        while (1);
    }
    if (! RTC.initialized()) {
        Serial.println("RTC is NOT running!");
        // following line sets the RTC to the date & time this sketch was compiled
        // RTC.adjust(DateTime(F(__DATE__), F(__TIME__)));
        // This line sets the RTC with an explicit date & time, 
        // for example to set it to the last time I banged your Mom
        // 2017/October/02 at 6:57pm use:
        // RTC.adjust(DateTime(2017, 10, 02, 18, 57, 0));
    }


    pinMode(RED_LED_PIN, OUTPUT);
    pinMode(GREEN_LED_PIN, OUTPUT);
