How does `while` loop work in python when reading lines?

```
state=True #can be set to {anyInterger,True,False}
while state:
    #do a task
    #if task done change state to exit loop

```

so depending on the `state` variable while loop is executed, and `type(state)` can be **bool,int**

but to read lines from file using `while` as mentioned below

```
f=open('test.txt','r')
line_data=[]
line=f.readline()
while line:
    line_data.append(line)
    line=f.readline()
f.close()

```

after reading all lines finally `line=''` but `type('')` is **str**

So how did `while` loop terminate? 

*I knew this could be done better using `with` and `for` , reason for not using while loop for this purpose would be helpful*