The problem is you can only write string data to a file, that is to say TEXT not numbers, or lists or anything else. So convert position to a string first by using the str() function:
position = str(position)
then it will write correctly.
Remember, when you read this information in from the file, you ALSO read it in as a string, not as a list. You have to convert it back into python code using the eval() function the same way you used str(), which will make it a list again.
-If you import the pickle module you can write all kinds of numbers,string tuples.It 's better especially if you want to read the value from the file later.