Why not use LineNumberReader
?
If you can't do that, what does the code look like?
The only difference I can think of is that you are splitting on a bad regex and that when you edit the file yourself, you get dos newlines that somehow pass your regex.
Still, for reading things one line at a time, it seems like overkill to use Scanner
.
Of course, why you are parsing /etc/passwd
is a hole other discussion :)