title: Python write to file
body: <p>I have a little problem in a small python script running on a debian server.</p>
  
  <p>First what it should do:<br />
   - Get the list from the server -> working<br />
   - Convert to real string list -> working<br />
   - Write to file -> Does nothing...<br /></p>
  
  <p>Already tried to use the same code in the python interface (>>>) and it writes everything the way it should.<br />
  Files are already created and got a chmod 777 on it.<br />
  Even checked if not accidentially another instance of that scipt is running which locks the file but nothing ...<br /></p>
  
  <p>Anyone got an idea why it won't write the files when started but in interface?</p>
  
  <p>And now here's the script itself:</p>
  
  <pre><code>#!/usr/bin/env python
  
  import urllib
  import sys
  import time
  import re
  
  exitNodes = []
  readableNodes = []
  class BlockTor():
      def getListFromWeb(myself):
          url = "https://www.dan.me.uk/torlist/"
          #url = "file:///E:/test.txt"
  
          try:
              for line in urllib.request.urlopen(url):
                  exitNodes.append(str(line, encoding='utf8'))
  
              for node in exitNodes:
                  readableNodes.append(re.sub('\\n', '', node))
              #print(exitNodes)
              #sys.exit()
          except:
              try:
                  f = open("/var/log/torblocker.log", "a")
                  #f = open("E:\\logfile.log", "a")
                  f.write("[" + time.strftime("%a, %d %b %Y %H:%M") + "] Error while loading new tornodes")
                  f.close()
              except:
                  print("Can't write log")
                  pass
              sys.exit()
              pass
  
  
      def buildList(myself):
          f = open("/etc/apache2/torlist/tor-ip.conf", "w")
          #f = open ("E:\\test-ips.conf", "w")
          f.write('&lt;RequireAll&gt;\n')
          f.write('   Require all granted\n')
          for line in readableNodes:
              f.write('   Require not ip ' + line + '\n')
          f.write('&lt;/RequireAll&gt;')
          f.close()
          try:
              f = open("/var/log/torblocker.log", "a")
              #f = open("E:\\logfile.log", "a")
              f.write("[" + time.strftime("%a, %d %b %Y %H:%M") + "] Sucessfully updated tor blacklist")
              f.close()
          except:
              pass
  
  
      def torhandler(myself):
          BlockTor.getListFromWeb(myself)
          BlockTor.buildList(myself)
  
  
  if __name__ == "__main__":
      asdf = BlockTor()
      BlockTor.torhandler(asdf)
  </code></pre>
  
  <p>EDIT:<br>
  Forgot to mention - If you want to test it be careful: This server allows only one request each 30minutes</p>