#------------------------------------------------------------------------------ # File3.py #------------------------------------------------------------------------------ f = open('Matrix.py') # default mode is 'r' read content = f.read() # reads entire file as one string f.close() words = content.split() print("There are {0} words in the file.".format(len(words))) # words.sort() # print(words) g = open('Matrix.py.bak', 'w') g.write(content) g.close()