append columns of data
<p>I have tab delimited data that I am exporting a select few columns into another file.  I have:</p>

<pre><code>a b c d
1 2 3 4
5 6 7 8 
9 10 11 12
</code></pre>

<p>and I get:</p>

<pre><code>b, d
b, d
2, 4
b, d
2, 4
6, 8
b, d
2, 4
6, 8
10, 12
......
</code></pre>

<p>I want:</p>

<pre><code>b, d
2, 4
6, 8 
10, 12
</code></pre>

<p>My code is </p>

<pre><code>f=open('data.txt', 'r')
f1=open('newdata.txt','w')
t=[]
for line in f.readlines():
    line =line.split('\t')
    t.append('%s,%s\n' %(line[0], line[3]))
    f1.writelines(t)
</code></pre>

<p>What am I doing wrong???  Why is it repeating?  </p>

<p>PLease help</p>

<p>Thanks!!</p>
