SD data logging for two sketches simultaneously

Hello, I am making a data logger for logging GPS, MPU6050 and BME 280 data. I have created two separate sketches for GPS and BME+MPU. But I am constanly failing when I try to combine sketches for logging. I have no idea how to run two simultaneous loops for storing GPS data in NMEA.txt and BME+MPU data in DATALOG.txt Please help me for making final sketch. My two separate sketches are in attachment.

gps_log.ino (6.97 KB)

BME280_and_MPU6050_data_logger.ino (10.2 KB)

Links to how to combine sketches

https://arduino-info.wikispaces.com/CombiningArduinoSketches

http://www.thebox.myzen.co.uk/Tutorial/Merging_Code.html

Planning and implementing a program. Using functions.

Using millis() for timing.

(deleted)

when I upload indivisual codes in arduino that time it works perfectly for GPS and BME+MPU . But when I combine the GPS and BME+MPU as per library-library, setup-setup and loop-loop ,smililar you can see in BME+MPU where I combined MPU and BME it doesnt working and not logging data. I am beginner hence I doesn't know how to run two loops. In first loop it will open sd and write data in NMEA.txt and close file and in next loop it will open sd and write data in DATALOG.txt and close it..How I do that?

14chougule:
I am beginner hence I doesn't know how to run two loops.

No surprise there. You can only have one loop. Read reply #1 again.