AIX system.... deleting files in remote directory after retrieving files

Hi Friends,
I am new to this , I am working on AIX system and my scenario is to retrive the files from remote system and remove the files from the remote system after retreving files. I can able to retrieve the files but Can't remove files in remote system. Please check my code and help me out .....I am struggling like:wall: Please help me on this code

sftp ...........@........... <<EOF
cd /home/............../DEV/HCL
get INVOICE*.xml /home/lidadm/ariba/invoice
quit
EOF
ls invoice/INVOICE*.xml >> filelist.txt ( from here is the mistake I guess )
while read N
do
echo >>todo.lst rm $N
done < filelist.txt
echo >>todo.lst quit
sftp ..........@........... < todo.lst
rm /home/............../DEV/HCL/&N
rm todo.lst
rm filelist.txt
Thanks in advance,
Vinay.

What makes you guess that the contents of the file are the mistake? What are its contents, and what should its contents be?

Dear Corona,

Thanks for your response ....Please see my comments below about the issue , I am sure you people can help me out to resolve this long issue

ls invoice/INVOICE*.xml >> filelist.txt ( Here I am getting the file list like invoice/INVOICE20110301-113424-950.XML here i will need to cut "invoice/" from the file list but thi is not the right place , Because it will not remove for all the files )
while read N
do
echo >>todo.lst rm $N ( I have to cut/remove "invoice/" from invoice/INVOICE20110301-113424-950.XML some where in this loop and add remote directory )
done < filelist.txt
echo >>todo.lst quit
sftp ..........@........... < todo.lst
rm /home/............../DEV/HCL/&N
rm todo.lst
rm filelist.txt

Thanks in advance,
Vinay.

Sorry, but to my mind this is gibberish. Please post what you actually typed (blotting anything confidential with X's), stating what you expected to happen and what actually happened with any error messages, backed directory listings or other evidence. Throughout please make it 100% clear which computer the commands were typed on an what software (e.g. Shell, sftp, ftp, whatever) you were running at the time.