title: Append a text line to a file and remove the first one if there are more than 4 lines in python
body: <p>I have an IRC client that people are chatting on while I broadcast my desktop. I wanted to show this on my broadcast and found a handy shock-wave flash title plug-in that can read text files and display them on the screen.</p>
  
  <p>My IRC client uses python scripts and can call a function every time someone write a message.</p>
  
  <p>I can write these text lines to a text file as they come in but I want some way of coding in python when there are more than 'say 4' lines of text in the file it removes the top one when adding the next one.</p>
  
  <p>I planned to do so by reading the text file when the append line function is called, reading the last 3 lines adding the new one then re-writing it to the original file.</p>
  
  <p>Of course when the script first runs there should be less then 3 lines in the file so the python should account for that also and only read the last 2 or 1 or 0 depending... </p>
  
  <p>I tried writing some code in a previous question but it didn't work so I won't include it here.</p>