Stop editing your scripts with Notepad. Windows saves carriage returns to the end of lines, breaking everything. Use a real editor inside your terminal, like nano or vim.
vi was designed for an ancient, minimal, and very alien keyboard, and emacs was designed for something even weirder... I've been scripting for years and still dont' use vi unless I have to. It's useful to learn since lots of unix systems have one or the other and nothing else, but if you install nano, I think you'll find it a lot more familiar.