title: Python - TypeError: expected string or bytes-like object
body: <p>I have the following code:</p>
  
  <pre><code>import re
  
  meshTerm = {}
  meshNumber = {}
  
  File = 'file.bin'
  with open(File, mode='rb') as file:
      readFile = file.read()
  
  outputFile = open('output.txt', 'w')
  
  for line in readFile:
      term= re.search(r'MH = .+', line)
      print(term)
  </code></pre>
  
  <p>When I run the code, I get the following error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "myFile.py", line 13, in &lt;module&gt;
      term = re.search(r'MH = .+', line)
    File "C:\Python35\lib\re.py", line 173, in search
      return _compile(pattern, flags).search(string)
  TypeError: expected string or bytes-like object
  </code></pre>
  
  <p>Why is that? How can I solve the issue?</p>
  
  <p>Thanks.</p>