title: Cannot remove the last line of a file using python
body: <p>I have the following that creates several csv files and putting at the end of each a character.
  When I open each of the file I notice an extra line I tried to remove it by using </p>
  
  <p>[:-1]</p>
  
  <p>but is not working</p>
  
  <pre><code> newlist = list(chunks(weblinks, 10))
   #PUT EACH LIST INTO FILE
   count = 0
   for nl in newlist:
       if nl:
           #CREATE FILE NUMBERING
           count=count+1
           with open('sktz'+str(count)+'.csv','w',encoding='utf-8',newline='') as f:
               writer = csv.writer(f, delimiter=";")
               #PLACE ON LAST ELEMENT A &gt;
               last_elem = nl[-1]
               last_elem[1] = last_elem[1]+'&gt;'
               nl[-1] = last_elem
  
               for each_elem in nl:
                   if each_elem:
                       writer.writerow(each_elem)
                       #writer.writerow(each_elem[:-1])
  </code></pre>