Replace Function In Python File Handling