improved python line counter