Move exit

Move exit from line 16 to include in IF statement on line 15. This was causing the script to exit regardless of the outcome of the IF statement, rather than only if no files were detected.