Debug: add pw.flush() when closing an XML element.