For better readability (and maybe solve the problem quicker), may I suggest formatting the GDscript with spaces. For each of the code snippets, indent them four spaces.
Anyway, you may be able to do that via the mechanism called serialization. You can save the lines in a file like this:
var file = File.new()
file.open("user://movement.txt", File.WRITE)
file.store_line(character_position)
file.close()
With this code, you could probably save the character's position to a file. Having written that, it may not be a great idea to constantly write the character's position to a file, as that could waste CPU cycles.