The following lines of code correspond to ambiguous redirect errors, respectively.
echo -e "\t<other>" >> $xml
echo "</direntry>" >> $xml
line 62: $xml: ambiguous redirect
line 76: $xml: ambiguous redirect
Looking around the site it seems that this problem stems from variables not having double quotes around them, but if I change $xml to "$xml" I get a no such file or directory error.