Look at lines 8-11 of the output that you originally posted, and lines 47-50 are the corresponding lines from the input xml. Notice how line 8 doesn't have the new lines, that because line 47 doesn't have the new lines. And similarly, lines 9,10,11 are on separate lines because lines 48,49,50 are on separate lines. It isn't the code _inserting_ any new lines, it is just copying them from the input.