I have the following piece of code:
for line in open(fileName, 'r'):
<do something>
Initially, I would assume that there is no need to close a file opened as read only, however after I have read through the answers to this question, it seems that I do have to close it, since Jython don't use reference counting and therefore won't close the file at the end of the loop.
How do I do that in this case, when I didn't define a file handler which I can close? Is such approach(as above) to open and read files is wrong?