The file is already closed (when the previous with
block finishes), so you cannot do anything more to the file. To reopen the file, create another with statement and use the read
attribute to read the file.
with open('test_output.txt', 'r') as f2:
data = f2.read()
print(data)