python code for manipulating files