public static String addLanguage(String eadfile, String language, String langCode)
            throws XMLStreamException, FactoryConfigurationError, IOException {

        String outputfile = eadfile.replace(".xml", SUFFIX + ".xml");


        FileInputStream fileInputStreamEAD = new FileInputStream(eadfile);
        XMLOutputFactory factory = XMLOutputFactory.newInstance();
        XMLEventWriter writer = factory.createXMLEventWriter(new FileWriter(
                outputfile));
        XMLEventFactory eventFactory = XMLEventFactory.newInstance();
        XMLEventReader xmlEventReaderEAD = XMLInputFactory.newInstance()
                .createXMLEventReader(fileInputStreamEAD);

        XMLEvent end = eventFactory.createDTD("\n");


        boolean eventAdded;

        while (xmlEventReaderEAD.hasNext()) {
            XMLEvent event = xmlEventReaderEAD.nextEvent();
            eventAdded = false;


            if (event.isStartElement()) {
                if (event.asStartElement().getName().getLocalPart().equals("revisiondesc")) {

                    writer.add(event);
                    eventAdded = true;

                    addRevisionChange(eventFactory, writer, end, language);

                }
            }
            /**
             * <profiledesc> <langusage> <language langcode="dut">Nederlands</language> </langusage> </profiledesc>
             */
            if (event.isEndElement()) {
                if (event.asEndElement().getName().getLocalPart().equals("profiledesc")) {


                    addLanguageXml(eventFactory, writer, language, langCode, end);

                    writer.add(event);
                    eventAdded = true;
                } else if (event.asEndElement().getName().getLocalPart().equals("eadheader")) {
                    if (!languageAdded) {
                        writer.add(end);
                        writer.add(eventFactory.createStartElement("", null, "profiledesc"));

                        addLanguageXml(eventFactory, writer, language, langCode, end);

                        writer.add(end);
                        writer.add(eventFactory.createEndElement("", null, "profiledesc"));
                    }
                    if (!revisionChangeAdded) {
                        writer.add(end);
                        writer.add(eventFactory.createStartElement("", null, "revisiondesc"));

                        addRevisionChange(eventFactory, writer, end, language);

                        writer.add(end);
                        writer.add(eventFactory.createEndElement("", null, "revisiondesc"));
                    }

                    writer.add(event);
                    eventAdded = true;
                }

            }

            if (!eventAdded) {
                writer.add(event);
            }
        }
        writer.close();
        return null;

    }