title: Python, EOF binary
body: <p>I'm trying to read a file in python as binary.
  Im interested in four bytes at a time, however I seem to be stuck in the infamous while loop:</p>
  
  <pre><code>with open(filename, "rb") as file:
        while file:
              file.read(4)
  
  print "EOF"
  </code></pre>
  
  <p>I've been trying this for the past hour, I never reach the end of the file, even in tiny text files. I did a "print test = file.read(4)" only to see that it prints "" </p>
  
  <p>How can I make sure it stops? My first idea was to make a if statement saying if file.read(4) (in a variable) == ""{4} or something, but this might actually appear in a file, right? so it could potentially stop in the middle of it.</p>
  
  <p>Is the only other option to beforehand calculate the size of the file? </p>