What's wrong with my Python for loop?
<p>I have two files open, EQE_data and Refl_data. I want to take each line of EQE_data, which will have eight tab-delimited columns, and find the line in Refl_data which corresponds to it, then do the data analysis and write the results to output. So for each line in EQE_data, I need to search the entire Refl_data until I find the right one. This code is successful the first time, but it is outputting the same results for the Refl_data every subsequent time. I.e., I get the correct columns for Wav1 and QE, but it seems to only be executing the nested for loop once, so I get the same R, Abs, IQE, which is correct for the first row, but incorrect thereafter.</p>

<pre><code>for line in EQE_data:
    try:
        EQE = line.split("\t")
        Wav1, v2, v3, QE, v5, v6, v7, v8 = EQE
        for line in Refl_data:
            Refl = line.split("\t")
            Wav2, R = Refl
            if float(Wav2) == float(Wav1):
                Abs = 1 - (float(R) / 100)
                IQE = float(QE) / Abs
        output.write("%d\t%f\t%f\t%f\t%f\n" % (int(float(Wav1)), float(QE), float(R) / 100, Abs, IQE))
    except:
        pass
</code></pre>
