For what value of 'best'? There are many ways that you could find the last line of a file. A good solution for one context may be bad in a different context. What are the interesting constraints for your application? For example:
- Do you know the maximum line length?
- Are the lines all the same length?
- Is the new line character consistent within the file
- Is the new line character consistent between files
- Is the file large (thousands of lines)?
- Does the task need to be performed many times a second?
- Does the code need to be written as baby Perl?
True laziness is hard work