copy a part of a text line from a text document into a new document
<p>I have a bunch of URL's in a text file but I'm only interested in one part of the URL and I want to save that part into another document. I've maneged to read 1 line at a time and then writing it to a file using this:</p>

<pre><code>from sys import argv
script, sol , save = argv

data = open(sol)
indata = data.read()


result = indata[51:85]   
result2 = "http://mars.jpl.nasa.gov/msl-raw-images/msss/00003/mcam/" + result + ".jpg"

output = open(save, 'w')
output.write(result2)

data.close()
output.close()
</code></pre>

<p>But I'm unable to port that into a for loop:</p>

<pre><code>from sys import argv
script, sol = argv

data = open(sol)
indata = data.read()

for line in indata:
   indata[51:85],


data.close()
</code></pre>

<p>I tried to print it in the screen to see why am getting it wrong but I only get empy lines. I'm stuck and I hope you can give me a hand.</p>

<pre><code>from sys import argv
script, sol, save = argv

data = open(sol)
indata = data.read()

def get_line():
    for line in indata.splitlines():
        print indata[51:85]

        result = indata[51:85]
        result2 = "http://mars.jpl.nasa.gov/msl-raw-images/msss/00003/mcam/" + result + ".jpg"

    output = open(save, 'w')
    output.write(result2)
    output.close()

get_line()    
data.close()
</code></pre>

<p>I've managed to do this but I can only save the first line in the new document. The rest are printed on the screen but not saved in the new document</p>
