No, the file will not be closed in this case.
See the example below
f.closed - Returns True if file is closed else False
# Your case
f1 = open('text.txt', 'r')
sum(1 for i in f1.readlines() if i.strip())
print(f1.closed)
# Using Context Manager
f2 = open('text.txt', 'r')
with f2:
sum(1 for i in f2.readlines() if i.strip())
print(f2.closed)
False
True
You can see that in the first case, the file is NOT closed where as in the second case, it is closed. So always use a context manager when reading & writing files.
From the Docs
It is good practice to use the with keyword when dealing with file objects. The advantage is that the file is properly closed after its suite finishes, even if an exception is raised at some point.