creeated lua pattern for filename finding
Range error checking

range input error checking for source template
removed unused variable
Tested on linux

removed comment
Made it look pretty
combined lines