When typing on a Mac using TextEdit, pay very close attention to the type of quotes it is generating. If “smart quotes” are turned on, this will destroy your code – the smart quotes are not the same characters as regular quotes. To turn off smart quotes, go into “Edit” -> “Substitutions” and make sure “Smart Quotes” is unchecked. In fact, I would turn off all the options here – each option represents some way that the text editor is going to replace what you type with what it thinks you should be typing. Since the editor is not a computer programmer, this is almost always not what you want to have happen. If you are getting smart quotes in other programs on any platform (Mac, Windows, Linux, etc.), there is almost always some way to turn them off.
If you aren’t sure if it is giving you smart quotes, type something in quotes, like “hello”. If the quotes on each side of the word look different from each other (one bends one way and the other bends the other way), you have smart quotes turned on.