The code as supplied works here,in that I get the first line of file1 for each line in file2 and then nothing as we have reached the end of file2 so the while loop needs to be reset if you wish to see further into file1 than line1.
Are you sure your output is from a run with the code you supplied?