CO2 sensor and GPS with Arduino Uno help

I have a CO2 sensor and Adafruit GPS module, and it has to log data using an SD card Shield that is compatible with arduino uno board but I'm having issues getting it to work. When I have it connected to the computer I can get it to display the GPS NMEA sentences and CO2 voltage and PPM reading but it won't record to the SD card consistently after it's plugged in to an external power.

Here is the equipment i have:

http://www.ebay.com/itm/For-Arduino-UNO-MEGA-2560-R3-SPI-SD-TF-Card-Micro-SD-Card-Shield-Expansion-Board-/272428843267?_trksid=p2385738.m2548.l4275

http://www.robotshop.com/en/adafruit-ultimate-gps-breakout-66-channel-mtk3339.html?gclid=Cj0KEQjwuOHHBRDmvsHs8PukyIQBEiQAlEMW0NdORFUv6fEf01JtkodbPa4JpbfkNdcTBWM0TFkuzqQaAsuM8P8HAQ

Here is the equipment i have:

And your code?

And an explanation of "it won't record to the SD card consistently after it's plugged in to an external power."?

What DOES it do? What external power?

This is the code that I run. The problem is when it logs data to the SD card. It manages to print a lot when it's plugged into the computer and the serial monitor shows a lot of data points, but in the SD card it only logs a maximum of 3 or less.
I attached the code below.

CO2_TEST_perfected.ino (10.4 KB)

  delay(3000); //sampling rate

You get GPS data every second. You can NOT stuff your head in the sand for 3 seconds.

  while(!GPS.newNMEAreceived()) //loops until it has a good NMEA sentence
    {
      letter = GPS.read();
    }

Reading from the port, even if there is nothing to read, is NOT a good idea.

 void clearGpsBuffer()// will clear the serial port buffer so data is not corrupted

That comment is nonsense. You use EVERY byte you read from the buffer.

    return pow(10, (volts - pcurve[1]) / pcurve[2] + pcurve[0]);
    volts = 0;

Anything after a return statement is stupid.