title: How to read a text file and check against its contents with python
body: <p>I am attempting to read a text file, print its contents, and stop when it reaches the "flag". </p>
  
  <p>My code is:</p>
  
  <pre><code> import sys
   sys.path.append("/Libraries/Documents")
   file = open("readmepython.txt", "r")
   while True:
       x = file.readline()
       if x != "break":
           print(x)
       else:
           break
  
   #doesnt work
  </code></pre>
  
  <p>The text file in question has only this inside of it with no extra spaces or returns:</p>
  
  <pre><code>this is the ip
  this is the /24
  this is the gateway
  this is the name server
  break
  </code></pre>
  
  <p>The loop will continue to run infinitely, and I am unsure how to properly assign the variable so that it checks properly.</p>
  
  <p>Does python not assign the raw string value when reading from a text file? What am I doing wrong here?</p>