# cat file reader with line numbering [duplicate]

You must do a program that reads a file given in first argument and print it's content to STDOUT and number the lines on the file, the numbers should be followed by a space.
For instance, assuming that your program is named cat, we could write ./cat "myfile.txt" (or execute it with its interpreter)

With myfile.txt:

Hello, world, this
is a file with
multiple characters..0


And the program should output to STDOUT :

1  Hello, world, this
2  is a file with
3  multiple characters..0


The shortest program in bytes win.

For example :

Perl

$r++&print"$r ".\$_ while<>

• Well, this one is a bit simpler than the Line numbering - implement nl. On this last one, there are restrictions on the length of the file and the program must return error codes. What I want to do here is the smallest program in many languages for just a simple thinks, no matter the length of the file and with only one file at a time. – tourdetour Dec 22 '15 at 18:38