Added writetoxml condition