title: AppleScript: "file is already open" but "file wasn't open"
body: <p>Because of my slightly obsessive personality, I've been losing most of my productive time to a single little problem.</p>
  
  <p>I recently switched from Mac OS X Tiger to Yosemite (yes, it's a fairly large leap).  I didn't think AppleScript had changed that much, but I encountered a problem I don't remember having in the old days.  I had the following code, but with a valid filepath:</p>
  
  <pre><code>    set my_filepath to (* replace with string of POSIX filepath, because typing
                            colons was too much work *)
      set my_file to open for access POSIX file my_filepath with write permission
  </code></pre>
  
  <p>The rest of the code had an error which I resolved fairly easily, but because the error stopped the script before the <code>close access</code> command, and of course AppleScript left the file reference open.  So when I tried to run the script again, I was informed of a syntax error:  the file is already open.  This was to be expected.</p>
  
  <p>I ran into a problem trying to close the reference:  no matter what I did, I received an error message stating that the file <i>wasn't</i> open.  I tried <code>close access POSIX file (* filepath string again *)</code>, <code>close access file (* whatever that AppleScript filepath format is called *)</code>, et cetera.  Eventually I solved the problem by restarting my computer, but that's not exactly an elegant solution.  If no other solution presents itself, then so be it; however, for intellectual and practical reasons, I am not satisfied with rebooting to close access.  Does anyone have insights regarding this issue?</p>
  
  <p>I suspect I've overlooked something glaringly obvious.</p>
  
  <hr>
  
  <p>Edit:  Wait, no, my switch wasn't directly from Tiger; I had an intermediate stage in Snow Leopard, but I didn't do much scripting then.  I have no idea if this is relevant.</p>