f = file(filename+".txt",'w')
in = raw_input(">")
This will open a file with the extention of .txt and then it will get a raw_input and write it to a text file and then add a new line and then close the file.
If what you are trying to write an integer to a text file make sure to do this:
yeah this might not be the fastest way but its the best i can do.