now works with multiple files

I never noticed that the script only worked for single file exports.
Now it works for multiple files.
fixed the array at the beginning. Added a for $i loop at the end for
the export.