Please strip out the new line from the hosts file:
   print "    <host>%s</host>" % hostList[i].strip()