title: TypeError: 'str' does not support the buffer interface
body: <pre class="lang-python prettyprint-override"><code>import hashlib
  
  infile = open("P:\\r.mp3", 'r+b')
  data = infile.readline()
  hash = hashlib.md5()
  hash.update(data)
  
  hash_digest = hash.hexdigest()
  print(hash_digest)
  #hash_digest = hash_digest.encode('utf-8')
  print(hash_digest)
  with open("lt.txt", 'ab') as outfile:
      outfile.write(hash_digest + '\n')   #error here
  
  with open("syncDB.txt", 'rb') as fg:
      for data in fg:
      print(data)
  </code></pre>
  
  <pre class="lang-none prettyprint-override"><code>outfile.write(hash_digest + '\n')
  TypeError: 'str' does not support the buffer interface
  </code></pre>
  
  <p>How do I correct that and what do I need to learn to see me through these situations?</p>
  
  <p>Also if I encode this in utf-8(uncomment) it gives out the following error:</p>
  
  <pre class="lang-none prettyprint-override"><code>TypeError: can't concat bytes to str
  </code></pre>