I was on a virtual machine and I started the editor with windows notepad and it converted the script to dos. So, I ended up installing dos2unix, which I used to convert the script. Then, the script worked.