title: How to iterate in a file inside a function in Python3?
body: <p>I have this function where I open two files, one for reading and one for writing. I iterate through <code>input_file</code> and I write some items from it to the <code>save_file</code>.</p>
  <pre><code>with open(input_file, 'r') as source, open(save_file, 'w') as dest:
          reader = csv.reader(source)
          writer = csv.writer(dest)
          
          for row in reader:
              #do_something
  
              find_min(save_file, threshold)
                  
  </code></pre>
  <p>Although through the iteration I want to call another function and iterate through the items that I have appended on the <code>save_file</code>, but when i call it and try to print them nothing is printed.</p>
  <p>This is the function that I call:</p>
  <pre><code>def find_min(file, threshold):
  
      with open(file, 'r') as f:
          reader = csv.reader(f)
          for i in reader:
              print(i)
  </code></pre>
  <p>If I try to call <code>find_min</code> function outside of <code>with</code> statement, the file is iterated normally and it's printed.</p>
  <p>But I want to call this function a lot of times in order to analyze and compress the initial data.</p>
  <p>So, does anyone know how to to iterate through the <code>save_file</code> in <code>find_min</code> function.</p>