How to append new columns on the side not the bottom
<p>I made a python script that takes a file with a lot of columns and extract and copy (into a new file) the two columns that I need. However, once or twice a month I will need to add additional columns to the same (new) file, but I need to add them to the side of the current columns, not to the bottom. how can I modify the script to do that?</p>

<p>These are some samples of input files.</p>

<p><a href="https://dl.dropbox.com/u/63216126/file5.txt" rel="nofollow">https://dl.dropbox.com/u/63216126/file5.txt</a></p>

<p><a href="https://dl.dropbox.com/u/63216126/file6.txt" rel="nofollow">https://dl.dropbox.com/u/63216126/file6.txt</a></p>

<p>Here is the code that I wrote.</p>

<pre><code>import sys
import re

filetoread = sys.argv[1]
filetowrite = sys.argv[2]

newfile = str(filetowrite) + ".txt"

openold = open(filetoread,"r")
opennew = open(newfile,"a")

rline = openold.readlines()

number = int(len(rline))
start = 0

for i in range (len(rline)) :
    if "2theta" in rline[i] :
        start = i

for line in rline[start + 1 : number] :
    words = line.split()
    word1 = words[1]
    word2 = words[2]
    opennew.write (word1 + " " + word2 + "\n")

openold.close()
opennew.close()
</code></pre>
