title: python utf-8-sig BOM in the middle of the file when appending to the end
body: <p>I've noticed recently that Python behaves in such non-obvious way when appending to the file using <code>utf-8-sig</code> encoding. See below:</p>
  
  <pre><code>&gt;&gt;&gt; import codecs, os
  &gt;&gt;&gt; os.path.isfile('123')
  False
  &gt;&gt;&gt; codecs.open('123', 'a', encoding='utf-8-sig').write('123\n')
  &gt;&gt;&gt; codecs.open('123', 'a', encoding='utf-8-sig').write('123\n')
  </code></pre>
  
  <p>The following text ends up to the file:</p>
  
  <pre><code>&lt;BOM&gt;123
  &lt;BOM&gt;123
  </code></pre>
  
  <p>Isn't that a bug? This is so not logical.
  Could anyone explain to me why it was done so?
  Why didn't they manage to prepend BOM only when file doesn't exist and needs to be created?</p>