The problem you’re having is that I’m going to guess that you’re using a different editor, not one within the Terminal.app environment on your Mac OS X system, and it’s saving the file with the wrong kind of end-of-line sequence.
You’ve got the basics nailed, though there’s a ton of cool things you can do with your shell prompt above and beyond what you’re trying to accomplish.