Ensure encoding header gets written at start of file
Ensure encoding header gets written at start of file

Check whether the file didn't exist beforehand or if we're
not appending (in which case the file gets written anew anyways.

ipython/ipython,ipython/ipython