title: Saving f.write file to same directory as the askopenfilename was found
body: <p>I am running this script in Python to find a certain line in a file. <code>askopenfilename</code> will ask what file I want to search and the f.write will save the results into a file. How do I automatically save this file in the same place I found the original file? </p>
  
  <pre><code>from tkFileDialog import askopenfilename
  
  filename = askopenfilename()
  
  file = open(filename, "r")
  for line in file:
      if "INF: Camera timeout" in line:
          with open("../timeouts.txt", "a") as f:
              f.write(line)
              f.close
  </code></pre>
  
  <p>Also <code>askopenfilename</code> opens behind the other windows, how do I make it open on top?       </p>