Well,
I think you have to remove doublequotes around the system()-call. It have to look like this:
$returnString = system("tail -n 1 file.txt");
This function returns a string of the complete output of the last operation. That's why, we use the "-n 1" option to tail only the last ONE line of the given file.
Further I think the intval function should work better on a single line, or, for the first trial, better don't use it so far (of course you have to be sure that the last field of your file-row is really a number and it can be converted into integer!)
So, hope it works now, if not, I'll check it out and code that snippet for you and then I can give you (hopefully) a full functioned snippet .... :-)
greetigs from Germany,
Michael.