title: Python 3 open() in binary mode not writing correct content
body: <p>So basically, I'm having a problem writing to bytes using python3. I've ensured that the content is as expected by using print, but it's still writing the incorrect content. It basically writes the first line copied 4 times. I'm using Latin-1. Essentially, the only raw bytes that I'm including in the b-strings are <code>0x80</code> and <code>0x81</code> (I.e. <code>\x80</code> and <code>\x81</code>). I write it using the building open() function in <code>"wb"</code> mode. Anybody have any idea what's going on?</p>
  
  <p>Edit: Here's the main method used to create the file. As stated, fs is a file opened in wb mode, and it prints as expected.</p>
  
  <pre class="lang-py prettyprint-override"><code>    def assemble_file(self, fs):
          "must call lex_from_asm_text before assembling"
          self.bin_raw_content += b"ROSAPYVM\x81"
          for x in self._asm_stripped:
              try:
                  bcode = bytes([ops.__dict__[x[0]]])
                  print(bcode)
                  print([x[1:]])
                  self.bin_raw_content += b"\x00"
                  self.bin_raw_content += bcode
                  for i in x[1:]:
                      self.bin_raw_content += b"\x80"
                      print(i.encode("latin-1"))
                      self.bin_raw_content += i.encode("latin-1")
              except IndexError:
                  pass
              print(self.bin_raw_content)
  
              fs.write(self.bin_raw_content)
  </code></pre>