Best to use join or append?
<p>Currently I have this code:</p>

<pre><code>with open(w_file, 'r') as file_r:
    for line in file_r:
        if len(line) &gt; 0:
          spLine = line.split()
          if(spLine[0] == operandID and spLine[1] == bitID
             and spLine[3] == sInstID and spLine[4] == opcodeID):
              spLine[-2]='1'
              line = ' '.join(spLine)  # I need to add a new line into
                                       # "line" after join all the spLine
          lines.append(line)
          print line
with open(w_file, 'w') as file_w:
    for line in lines:
       file_w.write(line)
</code></pre>

<p>The output:</p>

<pre class="lang-none prettyprint-override"><code>1 60 14039 470 13 0 28
1 60 14039 470 13 0 28
0 60 14039 470 13 1 281 60 14039 470 13 0 28  # I want to separate these two
1 60 14039 470 13 0 28                        # lines, this wrong situation
                                              # only happens when I found
                                              # the target line which
                                              # satisfies the if statement.
</code></pre>

<p>Just add a <code>+ "\n"</code> to the end, like this.</p>

<pre><code>line = ' '.join(spLine) + "\n"
</code></pre>

<p>This will add a new line after the joining. </p>

python join append