in reply to sed deleting file

This Perl works from the command line (add the -i if you test it and it seems safe). You can do similar tricks in a script with $^I.

perl -p -e 's/,(?=\)\Z)//' [file list]