You are trying to get second element (starting from zero) of the result of execution readlines method. It's unsafe by default as file can contain only one string.
But in this particular case you will receive empty list in fin.readlines() regardless to count of lines in opened file because you've already read lines above (using for line in fin loop). You can't just read it twice and need to seek to the beginning or reopen file:
~ echo 1 >> t.txt
~ echo 2 >> t.txt
~ echo 3 >> t.txt
~ python3
Twice reading contents:
>>> with open('t.txt') as f:
... f.readlines()
... f.readlines()
...
['1\n', '2\n', '3\n']
[]
Seeking to begin:
>>> with open('t.txt') as f:
... f.readlines()
... f.seek(0)
... f.readlines()
...
['1\n', '2\n', '3\n']
0
['1\n', '2\n', '3\n']
readlines()will produce nothing since you’re at the end of the file. Please see: ericlippert.com/2014/03/05/how-to-debug-small-programs. Can you explain what you’re trying to do with this code?