How to redirect 'print' output to a file using python?,f.close()