automated sftp procedure interrupted

Dear experts,

I have a local computer and remote computer (only sftp accessed).

I want to delete files x and y in both local and remote computer using the following automated script:

sftp $remote > /dev/null < mdel.file

the file mdel.file has been pre-created, and its content is
cd /usr/directory
rm x
rm y

The script works fine when both files x and y exhist in $remote computer.

The script is interrupted when file x does not exhist in $remote computer.
And therefore, the file y is not removed.

My question is, can I be able to remove file y in case the file x is not exhist?

The reason is that I can not gurantted that the file x exhist.

Many thanks

When I tested this myself the script just continued on and removed the second file anyway. If you remove the > /dev/null do you get any clues about why it is exiting?

$ touch delete1 delete2
$ echo 'rm delete1
> rm delete2' | sftp localhost
Connecting to localhost...
sftp> rm delete1
Removing /home/username/delete1
sftp> rm delete2
Removing /home/username/delete2
$ touch delete2
$ echo 'rm delete1^Jrm delete2' | sftp localhost
Connecting to localhost...
sftp> rm delete1
Couldn't stat remote file: No such file or directory
Removing /home/username/delete1
Couldn't delete file: No such file or directory
sftp> rm delete2
Removing /home/username/delete2
$

Thanks.

Boyin