Add Comment to Begining of xml File with Elementtree

I’m trying to build an xml file using elementtree. The first element of an xml file is a comment something like:

<!--version="1.0" encoding="UTF-8"-->

However, I cannot figure out how to add that to the beginning of the file. It seems like have to create the root node first in which case the comment follows the root node so the resulting file is invalid because it is missing the encoding. How do I output that line BEFORE the root node? TIA.

Never mind. I fixed as I was unaware of the XML declaration parameters when it writes: