Perl, 71 62 61 bytes
includes +1 for -n
$;=length($b+=y///c);$w+=split$"}{printf"%$;d %$;d $b",$.,$w
Commented:
while (<>) { # implicit because of -n
$; = length( # printf formatting: width
$b += y///c # count characters
);
$w += split $" # count words
}{ # explicit: end while, begin END block
printf "%$;d %$;d $b", $., $w # $. = $INPUT_LINE_NUMBER
} # implicit because of -n
- Save another byte, again thanks to @TonHospel.
- Save 9 bytes thanks to @TonHospel showing me a few tricks of the trade!