I'd be doing most of the work in GSAK, which directly supports text, GPX, LOC, Street Atlas route files (ANR), MapSend Waypoint files (WPT), OziExplorer WPT files, MapSource (MPS) files, MapSource GDB files, Streets & Trips EST files, Google Maps Route KML files, and Autoroute AXE files.
GSAK formats these files into files separating Lat and Lon with a comma and uses line break for new waypoint in the track, like this:
Code:
44.846498,-68.746948
44.854043,-68.763256
44.851123,-68.784885
44.837126,-68.795700
44.822395,-68.780079
44.822030,-68.749008
44.829335,-68.738537
44.841508,-68.772697
44.836517,-68.758965
44.843334,-68.752098
44.830065,-68.766174