rm files after testing for successful scp

First off, I know this is sort of a rehash of similar questions that have been asked in other closed threads, but I haven't been able to figure out how to apply the answers provided in those threads to my scenario and make it work.

I am working on a script in KSH on AIX 5.1 that will do a bulk unload of a DB2 table to a directory on the AIX server, then it should gzip the file and SCP it to a directory on a RHEL server and then remove the file from the AIX server (since space is very limited on the AIX server and some of these bulk unloads will be very large.)

scp2 /${extdir}/${tablename}.del.gz ${lzuser}@${lzserver}:/${lzdir}/ >> $logdir/$logfile 2>> $logdir/$logfile
 if [[ $? -ne 0 ]]
    then
    echo "SCP to Landing Zone failed, exiting script" >> $logdir/$logfile
    exit 100
    else
    echo "SCP to EPMA Landing Zone Successful, go ahead and remove the files." >> $logdir/$logfile
    rm /${extdir}/${tablename}.del.gz >> $logdir/$logfile 2>> $logdir/$logfile
    rm /${extdir}/${tablename}/*.load >> $logdir/$logfile 2>> $logdir/$logfile
fi

The problem I'm running into is that even if the SCP fails (I can force it to fail by specifying an invalid server name as the lzserver) the files are still being removed.

In the other threads on the topic, it showed putting the logic for testing the return code from SCP into a loop, but I don't understand how exactly to make that work. Also, I wasn't clear if the loop was something that would apply to my scenario or if it was particular to the other thread where it was dealing with finding log files and moving them.

Thanks in advance for the help!

After scp you can check if the file was successfully copied by doing:-

FNAME=$( ssh ${lzuser}@${lzserver} "ls /${lzdir}/${tablename}.del.gz" )
if [ "${FNAME}" = "${tablename}.del.gz" ]
then
      # Copy successful
else
      # Copy failed
fi