Made the write to xml conditional flag work