GPS and sensor data logger only works when connected to serial connection

Problem is I am a complete noob and I dont know how to do that or to check for other errors.

There is an on-board LED, usually on pin 13. Set the pin HIGH at places in the code, and LOW at other places. Or, create a function to blink the LED a number of times. Call that function with different numbers of times to blink at different points in the code - say 3 in setup() and 5 when you open the file, and 4 when the end of the GPS sentence arrives.

Soon, you'll know where you are getting to, and where you are not getting to.