title: Writing Arrays to a Tab Delimited Text File
body: <p>I apologize if this question is a duplicate; but none of the other posts have been of much use to me as of yet. I would like to output the arrays t and x from the following code into a text file with two columns, t being the first and x being the second, with a tab delimiter. The code I have so far looks like this:</p>
  
  <pre><code>import numpy as np
  
  tt = 10.0  #total time 
  dt = 1.0   #time step
  n = int(tt/dt) #number of iteration steps
  
  t = [0.0]*n #initialize an array of times, initially zero and with length n
  x = [0.0]*n #initialize x arry
  
  for i in range(n-1):
      x[i] = np.sin(4.0*t)
      t[i+1] = t[i] + dt
  
  with open('output.txt', 'a') as output:
      for a, am in zip(t, x):
          output.write("{}\t{}".format(a, am))
  </code></pre>
  
  <p>I have an empty text file named 'output', but nothing is getting written to it, much less two tab-delimited columns. Any help would be greatly appreciated. Thanks.</p>