title: Writing data on a single line using savetxt in Python
body: <p>What I want to do, is basically convert this Fortran code into Python:</p>
  <pre><code>open (1,file='file',form='formatted')       
  write (1,*) na,nb
  write (1,*) (a(i),i=1,na) 
  write (1,*) (b(j),j=1,nb)
  do i=1,na
     write (1,*) (f1(i,j),j=1,nb)
     write (1,*) (f2(i,j),j=1,nb)
  enddo
  </code></pre>
  <p>So I thought about using savetxt. The first difficulty I found, was the first line, where na and nb should be save on the same line in the file. I've found that you can achieve this with:</p>
  <pre><code>np.savetxt(&quot;file.txt&quot;,(na,nb),fmt='%s',newline=&quot; &quot;)
  </code></pre>
  <p>The problem, is then whenever I want to write the second line as:</p>
  <pre><code>f=open(&quot;file.txt&quot;,'f')
  np.savetxt(f,a,fmt='%s',newline=&quot; &quot;)
  </code></pre>
  <p>The array a gets added on the same line as na and nb, while I want it to be so on a new one. I can't figure out how to do this. I thought that with newline=&quot; &quot;, I just had to add &quot; &quot; to na,nb, but it doesn't work. Alternatively, what would be the cleanest way to write that Fortran code?</p>