title: AppleScript to read strings from ".txt" files to variables
body: <p>I am trying to build an AppleScript that reads each line of a “.txt” file (with a linefeed) and stores the contents of each line into AppleScript variables.</p>
  
  <p>Here is what I mean: </p>
  
  <p>Let’s say there was a “Test.txt” file with the contents:</p>
  
  <pre><code>Apples  
  Oranges  
  Pears  
  </code></pre>
  
  <p>As you can see, the “Test.txt” file’s contents have a String on each line, a linefeed introducing the new String, and so on.</p>
  
  <p>I would really like to know how an AppleScript could be made so that each line’s Strings are copied into individual AppleScript variables. </p>
  
  <p>(This way, “Apples” in the first line, would be stored in variableA, “Oranges” in the next would be stored in variableB, “Pears” … variableC, etc.)</p>
  
  <p>Please let me know, from your experience, how best to accomplish this. I know it’s slightly more involved, here is where I am:  </p>
  
  <pre><code>(* 
  This portion of the AppleScript accesses the contents of the ".txt" file named "Test," though takes all of the content and places it into a single variable. 
  *)
  
  set newFile to ("Macintosh HD:Users:Username:Desktop:Test.txt")
  set theFileContents to (read file newFile)
  
  { AppleScript code to read each line to individual variables }
  </code></pre>
  
  <p>I know there must be others trying to accomplish this.</p>