that is because you have entered a wrong file mode. You used r
which stands for reading while you should use the w
for the writing. That code should work.
a = open("movies.txt","rw")
a.write("EndGame")
a.close()
3
solved Writing and reading files [duplicate]