updated countlines to be less dumb