Replace open-try-finally with 'with open'