title: python nested loop using files and if condition not working
body: <p>I have:</p>
  
  <pre><code>master = open('master.txt', 'r')
  transaction = open('transaction.txt', 'r')
  
  master_list = []
  employee_list = []
  
  
      for line in master:
          # split the line
          record = line.split(',')
          # extract id from record
          emp_id = record[0]
          # add id to list
          employee_list.append(emp_id)
  
          for li in transaction:
              # split the line
              rec = li.split(',')
              i_d = rec[3]
              print(i_d)
  </code></pre>
  
  <p>This works as expected and outputs</p>
  
  <pre><code>001
  001
  001
  001
  001
  002
  002
  002
  002
  002
  003
  003
  003
  003
  003
  004
  004
  004
  004
  004
  005
  005
  005
  005
  005
  </code></pre>
  
  <p>but if I use an if statement in the nested loop like this:</p>
  
  <pre><code>for li in transaction_file:
              # split the line
              rec = li.split(',')
              i_d = rec[3]
              if i_d == emp_id:
                  print(emp_id)
  </code></pre>
  
  <p>I only get 001 001 001 001 001</p>
  
  <p>why is that?</p>