Its End of Line(EOL) conversion issue when script is written in windows using some editors like notepad, notepad++(tested).
Sed , tr may solve the issue in case of you just need to run script, however if you are developing shell script its become annoying each time first convert using, sed/tr command then run your script.
Notepad++ has an option to convert END OF LINE CONVERSION(EOL).
How to do that:
go to Edit > EOL Conversion > select Unix/OSX
Here you go, save script file and run it.
Here is screenshot of the same