title: Binary text isn't found in a binary file
body: <p>I opened a file in binary mode. I need to find a certain string inside this file and print the line after that. However, the string doesn't appear to be found in the text file. I looked into the text file manually, and the string is definitely found on one line.</p>
  
  <p>I tried opening the file as textfile (not binary mode) and not making the string binary, but that gave an error that I solved with <a href="https://stackoverflow.com/questions/33054527/typeerror-a-bytes-like-object-is-required-not-str-when-writing-to-a-file-in">this question</a>. The answer on that question led to the below (and current) code.</p>
  
  <pre class="lang-py prettyprint-override"><code>with open(os.path.join(directory, filename), 'rb') as read_obj:
      # print(read_obj.read())
      for line in read_obj:
          line_number += 1
          if b"PREPARED FOR" in line:
              break
          print(line_number)
  </code></pre>