Losing one line of text file in For Loop
<p>My For loop skips the first line each time I read one line at a time.
The problem doesn't occur when I just need to read in the entire file into memory, but mostly I need to read in one line a at a time.</p>

<p>Here's one example where the problem occurs.
This loop just reorders the elements in a list.
I've omitted the lines where I open and close read &amp; write files (the clunky way I do it). Its all comma delimited text data.</p>

<pre><code>lineString=fileItemR.readline()

for lineString in fileItemR:
    lineList = lineString.split(",")
    newList = (lineList[1],lineList[0],lineList[2:99])
    lineItem = str(newList)
    formatString = lineItem.replace("('","").replace("', '",",").replace("', ",",").replace("['","").replace("\\n","\n").replace("'])","")

    fileItemW.write(formatString)
</code></pre>
