There are improvements that can be made to the script, but the script itself is not generating the error. That's an error generated by the shell. The error message is telling you that the shell couldn't find the script.

How are you executing the script?

Are you executing it from the same directory where it's located and if so, are you specifying the path?