title: Python Print Output Executing Out of Order
body: <p>with respect to my code below (Python language), why does the following print statement (in the get_a_maximal_subset function)</p>
  
  <pre><code>    file = open("_probe","a")
      file.write("\n new_ref_array: \n")
      file.write(str(new_ref_array))
      file.close
  </code></pre>
  
  <p>get printed to the file before the (in the reference code below)</p>
  
  <pre><code>                        file = open("_probe","a")
                          file.write("\n local_array \n")
                          file.write(str(local_array))
                          file.close
  </code></pre>
  
  <p>I get the following output in the _probe file:</p>
  
  <p>test point 2 </p>
  
  <p>test point 3 </p>
  
  <p>test point 3-b </p>
  
  <p>test point 3-c </p>
  
  <p>new_ref_array: </p>
  
  <p>[10, 1]</p>
  
  <p>new_ref_array: </p>
  
  <p>[10, 1]</p>
  
  <p>local_array </p>
  
  <p>[10, 1]</p>
  
  <p>test point 4 </p>
  
  <p>ISSUE: it seems that the "local array" should be printed BEFORE instead of after the "new_ref_array" lines, since the "new_ref_array" lines are from the get_a_maximal_array function and the code order is:</p>
  
  <pre><code>                        local_array = list(array[i:])
                          file = open("_probe","a")
                          file.write("\n local_array \n")
                          file.write(str(local_array))
                          file.close
                          i = i + 1
                          subset_candidate = get_a_maximal_subset(local_array, max, prefix)
  </code></pre>
  
  <p>====================MY CODE BELOW===========================================</p>
  
  <pre><code>                while (determination_process == True):
                      file = open("_probe","a")
                      file.write("\n test point 2 \n")
                      file.close
                      i = 0
                      for x in array:
                          file = open("_probe","a")
                          file.write("\n test point 3 \n")
                          file.close
                          prefix = []
                          local_process_ref = [max+1]
                          if (determination_process != True):
                              break
                          if (x not in global_process_ref):
                              file = open("_probe","a")
                              file.write("\n test point 3-b \n")
                              file.close
                              global_process_ref.append(x)
                              file = open("_probe","a")
                              file.write("\n test point 3-c \n")
                              file.close
                          local_array = list(array[i:])
                          file = open("_probe","a")
                          file.write("\n local_array \n")
                          file.write(str(local_array))
                          file.close
                          i = i + 1
                          subset_candidate = get_a_maximal_subset(local_array, max, prefix)
                          file = open("_probe","a")
                          file.write("\n test point 4 \n")
                          file.close
  </code></pre>