Python scripts that work with files can look simple until something goes wrong. Your script may read the correct file during class, then fail when a filename contains a space ...
I may have given this a rather grand title, but what I am introducing this time is simply reading a text file, replacing some ...