title: Python script not writing to file when executed at boot
body: <p>I am trying to make a python loop script that will write to a file.</p>
  
  <p>When I execute the script in terminal, the file gets written with no issue.</p>
  
  <p>I wan't this script to start on boot, so I put it in the rc.local file. The script runs, however it is not writing the output to the specified file..</p>
  
  <p>I did some reading on flushing and un-buffered output.. 
  Could anyone help me out or point me in the right direction?</p>
  
  <p>When this script is finished it will send the file using REST, but I need the file to write before I even get there..</p>
  
  <p>The script:</p>
  
  <pre><code>#!/usr/bin/python -u
  
  while True:
      try:
          print "This is only a test..."
          with open("loop.txt", "a") as loopFile:
              loopFile.write("This is only a test...")
              loopFile.write('\n')
              loopFile.flush()
              loopFile.close()
          time.sleep(1)
      except KeyboardInterrupt:
          break
          quit()
  </code></pre>
  
  <p>The /etc/rc.local file:</p>
  
  <pre><code>/usr/bin/python /home/pi/loop.py &amp;
  </code></pre>
  
  <p>loop.py and loop.txt both have read/write/execute access.</p>