 
   File log_file = SD.open("log.csv", FILE_WRITE);
 
-  print(gps.location.lat(), 6);
-  print(',');
-  print(gps.location.lng(), 6);
-  print(',');
-  print(gps.time.hour());
-  print(',');
-  print(gps.time.minute());
-  print(',');
-  print(gps.time.second());
-  print(',');
-  print(gps.date.day());
-  print(',');
-  print(gps.date.month());
-  print(',');
-  print(gps.date.year());
-  print(',');
-  print(gps.speed.mph());
-  print(',');
-  print(map(CO,  0, 1023, 20,  2000)); //ppm
-  print(',');
-  print(map(CO2, 0, 1023,  0, 10000)); //ppm
-  print(',');
-  print(map(O3,  0, 1023, 10,  2000)); //ppb
-  print(',');
-  print(map(NO,  0, 1023, 50, 10000)); //ppb
-  print(',');
-  print(map(TEMP, 0, 1023 , -40, 125)); // celsius
-  print(',');
-  print(map(WIND, 0, 1023 , 0, 100)); // meter per second
-  println();
+  fprint(gps.location.lat(), 6);
+  fprint(',');
+  fprint(gps.location.lng(), 6);
+  fprint(',');
+  fprint(gps.time.hour());
+  fprint(',');
+  fprint(gps.time.minute());
+  fprint(',');
+  fprint(gps.time.second());
+  fprint(',');
+  fprint(gps.date.day());
+  fprint(',');
+  fprint(gps.date.month());
+  fprint(',');
+  fprint(gps.date.year());
+  fprint(',');
+  fprint(gps.speed.mph());
+  fprint(',');
+  fprint(map(CO,  0, 1023, 20,  2000)); //ppm
+  fprint(',');
+  fprint(map(CO2, 0, 1023,  0, 10000)); //ppm
+  fprint(',');
+  fprint(map(O3,  0, 1023, 10,  2000)); //ppb
+  fprint(',');
+  fprint(map(NO,  0, 1023, 50, 10000)); //ppb
+  fprint(',');
+  fprint(map(TEMP, 0, 1023 , -40, 125)); // celsius
+  fprint(',');
+  fprint(map(WIND, 0, 1023 , 0, 100)); // meter per second
+  fprintln();
 
   log_file.close();
 }

// code!
//#define DEBUG
#ifdef DEBUG
#define print   Serial.print
#define println Serial.println
#else
#define print   log_file.print
#define println log_file.println
#endif

int sensor_array[6];

  Serial.begin(9600);
  gps_port.begin(GPS_BAUD_RATE); //GPS Setup

  #ifndef DEBUG
  //SD card start
  pinMode(SD_PIN, OUTPUT);
  digitalWrite(SD_PIN, HIGH);
  SD.begin(SD_PIN);

  //print header
  if(!SD.exists("log.csv")) {
    File log_file = SD.open("log.csv", FILE_WRITE);
    log_file.println("latitude,longitude,hour,minute,second,day,month,year,speed (in mph),CO (in ppm),CO2 (in ppm),O3 (in ppb),NO (in ppb),tempurature (in celsius),wind speed (in meters per second)");
    log_file.close();
  }
  #endif
}

void loop() {
