title: Flask not writing to file
body: <p>I've been meaning to log all the users that visit the site to a file.
  Using Flask for the backend.
  I have not been able to get python to write to the file. Tried keeping exception handling to catch any errors that might be generated while writing. No exceptions are being raised.
  Here is the part of the blueprint that should write to file.</p>
  
  <pre class="lang-python prettyprint-override"><code>from .UserDataCache import UserDataCache
  udc = UserDataCache()
  
  @main.route('/')
  def index():
      s = Suggestion.query.all()
      udc.writeUsertoFile()
      return render_template('suggestions.html', suggestions = s)
  </code></pre>
  
  <p>Here is the UserDataCache class:</p>
  
  <pre class="lang-python prettyprint-override"><code>from flask import request
  from datetime import datetime
  
  class UserDataCache():
      def __init__(self):
          pass
  
      def writeUsertoFile(self):
  
          try: 
              with open("userData.txt","a") as f:
                  f.write(str(datetime.now()) + " " + request.remote_addr + " " + request.url + " " + request.headers.get('User-Agent') + "\n")
          except IOError,e:
             print e
          return
  </code></pre>