FTP inside a block of code

I need help on the code below. I am getting a compile error
syntax error at line 283 : `<<' unmatched

Looks like it doesn't like the << on the ftp line below. If I ran the code outside of this block everything work fine, but when I put in a block of code or in a function, I got syntax error. I wrote these codes in ksh.
if [ ${agentCount} -eq 1 ]
then
echo "Going to ftp ${DATAPATH}${AGTFILE}.asc"

ftp -i -v ${JQFTPSERVER} << EOF >> ${ftpout}

cd to_jq
pwd
ascii
prompt
put ${DATAPATH}${AGTFILE}.asc

bye
EOF
fi

I found the solution to my problem. the problem was I indent EOF and it should be at the first position on the left.