title: Save arrays from loop in one txt file in columns
body: <p>I'm creating an array of zeros (587x1) in which I want to replace a zero with a one in a specific line of the array given as an index from another file. This part works fine in my code so far. </p>
  
  <p>Afterwards, I want to save all these newly created arrays in one txt file as columns next to each other, separated by tabs. What my code does, however, is overwriting the arrays. How do I manage to append them next to each other in one file?</p>
  
  <p>Thanks a lot for your help!</p>
  
  <p>Update: I managed to write all the arrays to one file, however, they are now simply printed on top of each other - how do I write them to columns appearing next to each other?</p>
  
  <pre><code>import os
  import numpy as np
  participants = ['001']
  for vp in participants:
     with open('file.txt') as f:
        content = f.readlines()
     content = [x.strip() for x in content]
     content = map(int, content)
  f = open(outfile.txt, 'w')       
  for line in content:
        with open('outfile.txt', 'a') as f:
              arr = np.zeros((587, 1), dtype = int)
              np.put(arr, [line], [1])
              np.savetxt(f, arr, fmt='%i')
  f.close()
  </code></pre>