Maybe it's just me, but aren't you first counting lines of a file and then iterating over each line in the same file and appending line count to each line? Effectively reading through the file twice.
Looks like a bug to me...
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.