I have a file \"test.txt\":
this is 1st line this is 2nd line this is 3rd line
the following code
lines = open(\"test.txt\"
It is not only an iterable, it is an iterator, which is why it can only traverse the file once. You may reset the file cursor with .seek(0) as many have suggested but you should, in most cases, only iterate a file once.
.seek(0)