title: file.seek() and file.write() issue when writing to a binary file
body: <p>So, I have my code set up to read an array and write it to a binary file.</p>
  
  <pre><code>import sys
  import pickle
  offset = 0
  UncompressedLookup = {}
  f = open('/Users/shivangisingh/Desktop/InformationRetrieval/UCIndex.txt', 'wb')
  for k, v in uncompressed_dic.items():
      UncompressedLookup[k] = {'offset': offset,
                               'size': sys.getsizeof(v),
                               '#ofdocumnetsInCollection': termstats[k]['#ofdocumnetsInCollection'] ,
                               '#ofoccurancesInCollection' : termstats[k]['#ofoccurancesInCollection'] }
      f.seek(offset)
      pickle.dump(v,f)
      offset= f.tell()
  
  f.close()
  </code></pre>
  
  <p>When I print a few occurrences of the <code>UncompressedLookup</code>:</p>
  
  <pre><code>i=0
  for k, v in UncompressedLookup.items():
      if (i==5):
          break
      print(k,v)
  </code></pre>
  
  <p>I get:</p>
  
  <pre class="lang-none prettyprint-override"><code>scene {'offset': 0, 'size': 19152, '#ofdocumnetsInCollection': 747, '#ofoccurancesInCollection': 779}
  venice {'offset': 5071, 'size': 1096, '#ofdocumnetsInCollection': 25, '#ofoccurancesInCollection': 78}
  </code></pre>
  
  <p>That is weird because when I start at 0 and pickle 19152 bytes of data the next offset should be at 19152 but as we can see it is at 5071. I am confused.</p>