title: Read textfile into list in Applescript
body: <p>I tried to create an AppleScript that reads a text file and puts the contents into a list. The file is a simple text file where every line looks like this: <code>example-"example"</code></p>
  
  <p>The first is a filename and the other is a folder name.</p>
  
  <p>Here is my code now:</p>
  
  <pre><code>set listOfShows to {}
  set theFile to readFile("/Users/anders/Desktop/test.txt")
  set Shows to read theFile using delimiter return
  repeat with nextLine in Shows
      if length of nextLine is greater than 0 then
          copy nextLine to the end of listOfShows
      end if
  end repeat
  choose from list listOfShows
  
  
  on readFile(unixPath)
      set foo to (open for access (POSIX file unixPath))
      set txt to (read foo for (get eof foo))
      close access foo
      return txt
  end readFile
  </code></pre>
  
  <p>When I run that the output I get this:</p>
  
  <pre><code>error "Can not change \"Game.of.Thrones-\\\"Game Of \" to type file." number -1700 from "Game.of.Thrones-\"Game Of " to file"
  </code></pre>
  
  <p>My list looks like this: Game.of.Thrones-"Game Of Thrones" and two more lines like that.</p>