public XMLWriter closeTag() {
        if (openTags.size()<=0) {
            throw new RuntimeException("Called closeTag() when no tag was open");
        }
        Utf8String lastOpenTag=openTags.remove(openTags.size()-1);

        if (inOpenStartTag) {// this tag has no content - use short form
            w(EGT);
        }
        else {
            if (currentIsMultiline) {
                w(LF).indent();
            }
            w(ELT).w(lastOpenTag).w(GT);
        }
        if (openTags.size()==0 || openTags.size()<=maxLineSeparatorLevel) {
            w(LF);
        }
        inOpenStartTag=false;
        currentIsMultiline=true; // When we go up from a subtag we are at a multiline tag (because it contains subtags)
        isFirstInParent=false;   // the next opened tag will not be first
        return this;
    }
Writes the first line of an XML file
vespajlib/src/main/java/com/yahoo/text/XMLWriter.java