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