You're attempting to loop through the contents of f
twice:
for line in f:
for linez in f:
... and you can't do it that way. The second loop will exit immediately, because you already read all of the lines; there are none left to read.
If you want to save the lines of a file and loop through them several times, use something like this:
all_lines = f.readlines()