IO.UnsupportedOperation: Not Writable
<p>I have made a program where it stores a score attached with a name in a <em>.txt</em> file. However, I want to then print the alphabetical order of the name attached to the score. But when I run the program it come up with the error <code>io.UnsupportedOperation: not writable</code>
Here my code:</p>

<pre><code>            file = open(class_name , 'r')       #opens the file in 'append' mode so you don't delete all the information
            name = (name)
            file.write(str(name + " : " )) #writes the information to the file
            file.write(str(score))
            file.write('\n')
            lineList = file.readlines()
            for line in sorted(lineList):
                print(line.rstrip());
                file.close()
</code></pre>