title: What value does readline return when reaching the end of the file in Python?
body: <p>One can use the classic loop</p>
  
  <pre><code>file_in = open('suppliers.txt', 'r')
  line = file_in.readline()
  
  while line:
      line = file_in.readline()
  </code></pre>
  
  <p>to read through a file line-by-line in Python.</p>
  
  <p>But what value does 'line' have when the loop exits?  The Python 3 docs only read:</p>
  
  <blockquote>
    <p><strong>readline(size=-1)</strong></p>
    
    <p>Read and return one line from the stream. If size is specified, at
    most size bytes will be read.</p>
    
    <p>The line terminator is always b'\n' for binary files; for text files,
    the newline argument to open() can be used to select the line
    terminator(s) recognized.</p>
  </blockquote>
  
  <p><strong>Edit</strong>:</p>
  
  <p>In my version of Python (3.6.1), if you open a file in binary mode, <code>help(file_in.readline)</code> gives</p>
  
  <pre><code>readline(size=-1, /) method of _io.BufferedReader instance
  
      Read and return a line from the stream.
  
      If size is specified, at most size bytes will be read.
  
      The line terminator is always b'\n' for binary files; for text
      files, the newlines argument to open can be used to select the line
      terminator(s) recognized.
  </code></pre>
  
  <p>which is exactly the same as the <a href="https://docs.python.org/3/library/io.html#io.IOBase.readline" rel="noreferrer">docs quoted above</a>. But, as noted by <a href="https://stackoverflow.com/a/45019414/1048186">Steve Barnes</a>, if you open the file in text mode, you get a useful comment. (Oops! Copy-paste error on my part)</p>