Using sed command to change end of line

I am looking to change a data file into a javascript string and this is the code that I am using:

sed -i '' -e 's/^/str += "/' -e 's/$/";/' file.xml

The first part

-e 's/^/str += "/'

works as intended, but the second part

-e 's/$/";/'

adds an additional newline to my file, so that instead of this:

str += "<?xml version="1.0" encoding="UTF-8"?><!--";

the following is the result:

str += "<?xml version="1.0" encoding="UTF-8"?><!--
";

How do I fix this?

In regular expression parlance a $ does mean EOL. Try escaping it?

\$

was this xml transferred from another system? Your script works for me.

Your last suggestion actually turns out to be the answer, I just noticed using ee. Thanks