here is short reproduction example:
the wrong line is the second XML header in the created file
here is the full story:
Here is the code what is wrong:
There is how to fix it:
Here is proof of concept:
I created the pull request
Thanks for the bug report and fix.
I created a new pull request with your fix and test case.
Fixed in mono/master 355d2c5eca6ec320ccd4097d7f196b26a721ea94.
Fixed in mono/mono-4.3.2-branch 96e0145891be996cc224c8c7ae1d05d6ba1abeb1.
This will be in Cycle 7.
*** Bug 38460 has been marked as a duplicate of this bug. ***