title: Problem using cPickle
body: <p>Could you helpme to make this exmaple work?</p>
  
  <p>I'd like to load a serialized dict if it exists, modify it and dump it again. I think I have a problem with the mode I'm using to open the file but I don't know the correct way.</p>
  
  <pre><code>import os
  import cPickle as pickle
  
  if os.path.isfile('file.txt'):
      cache_file = open('file.txt', 'rwb')
      cache = pickle.load(cache_file)
  else:
      cache_file = open('file.txt', 'wb')
      cache = dict.fromkeys([1,2,3])
  
  # modifications of cache
  
  pickle.dump(cache, cache_file)
  cache_file.close()    
  </code></pre>
  
  <p>Run it twice to see the error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "example.py", line 11, in &lt;module&gt;
      pickle.dump(cache, cache_file)
  IOError: [Errno 9] Bad file descriptor
  </code></pre>