an easier way of reading the file would be using the file() command wich reads an entire file into an array without having to call fopen() etc...
But when you'r using huge files it's best to seek to the end of the file and using rewind to get the last 20