I have the following test script:
Your code runs fine.
Use Notepad2 or Notepad++ if you're working on Windows. The built-in Notepad is unable to cope with Unix-style line endings.