Bad arguments to replace all Need Help

I have made a status saver app and when i saved the first image it show an error but if i swipe to next it doesn’t show error. Don’t know Why this problem occurred.

Here is the SS of Error.

And here is the Code.

It’s because PhotoList.Selection is empty.

But when I swipe the image and then save it . Then it doesn’t show error.
How to solve this problem pls tell me.