About line 129 of this script, the following appears:
EOFBUILDFAILUREMSG
remove the leading white space from this line and your error message will disappear.
This is the final delimiter of the document. If line 123 was changed so that the forwarding operator was <<-, you could go to the leading white space, and the space consisted only of tabs (without spaces):
cat <<-EOFBUILDFAILUREMSG >>${MAILLOG}