Fixed scope of try-finally block where file might not be deleted.