To open a file, it must be referred to by its identifier, for example:
file = open("demofile.txt","r")
This would open the file and allow its contents to be read.
file = open("demofile3.txt","w")
This would open the file and allow it to have data written to it.
file = open("demofile2.txt", "a")
This would open the file and allow you to append it.
file.close()
This would close the file