diff --git a/lib/ansible/modules/network/nxos/nxos_snapshot.py b/lib/ansible/modules/network/nxos/nxos_snapshot.py index 7b7d81781f..ed113c6f70 100644 --- a/lib/ansible/modules/network/nxos/nxos_snapshot.py +++ b/lib/ansible/modules/network/nxos/nxos_snapshot.py @@ -561,8 +561,9 @@ def write_on_file(content, filename, module): path += '/' filepath = '{0}{1}'.format(path, filename) try: - with open(filepath, 'w') as report: - report.write(content) + report = open(filepath, 'w') + report.write(content) + report.close() except: module.fail_json(msg="Error while writing on file.")