Problem with my program with libraries adafruit_gps.h and SD.h

Of course the second program works. It just doesn't produce the results that you want. What it does and what you want you kept to yourself, though, so we can't help you.