title: Nested loops with Python cPickle
body: <p>I would like to be able to have a series of nested loops that use the same pickle file. See below:</p>
  
  <pre><code>def pickleRead(self):
      try:
          with open(r'myfile', 'rb') as file:
              print 'Reading File...'
              while True:
                  try:
                      main = pickle.load(file)
                      id = main[0]
                      text =  main[1]
                      while True:
                          try:
                              data = pickle.load(file)
                              data_id = data[0]
                              data_text = data[1]
                              coefficient = Similarity().jaccard(text.split(),data_text.split())
                              if coefficient &gt; 0 and data_text is not None:
                                  print str(id) + '\t' + str(data_id) + '\t' + str(coefficient)
                          except EOFError:
                              break
                          except Exception as err:
                              print err
                  except EOFError:
                      break
  
              print 'Done Reading File...'
          file.close()
      except Exception as err:
          print err 
  </code></pre>
  
  <p>The second (inner) loop runs without any problems but the first one just does a single iteration and then stops. I am trying to grab a single row at a time then compare it against every other row in the file. There are several thousand rows and I have found that the cPickle module out performs anything similar. The problem is that it is limited in what is exposed. Can anyone point me in the right direction?</p>