title: cProfile , how to log the data to a file
body: <p>I am a complete beginner using python and I been asked to log the profile for every time I run a given a simulation. My simulation has 4 classes and 10 methods that run in a loop until aa certain condition is achieved.</p>
  
  <p>I have written the follow file that creates the file:</p>
  
  <pre><code>LOG_FILE = open(os.path.join(os.getcwd(), "logs", "Log_Log_{}.txt".format(
     str(datetime.datetime.now()).replace(":", "_"))), mode="w") 
  </code></pre>
  
  <p>Right at the bottom of the script I added:</p>
  
  <pre><code>if __name__ == "__main__":
      cProfile.run("main()", LOG_FILE, sort="tottime")
  </code></pre>
  
  <p>Why is my Log_Log file blank and cProfile not returning anything?</p>