Count lines and use in error message