Nice idea!
You can also do this with PyFilesystem...
fs.gettext('/home/amyjess/stuff/foo.txt')
fs.settext('/home/amyjess/stuff/foo.txt', bar)
There are equivalent bytes methods.