SED - Numbering - Number each line of a file (but only print numbers if line is not blank)

sed '/./=' filename | sed '/./N; s/\n/ /'

Example

Running that command again this file:

testfile
aaa
bbb
ccc

returns:

testfile
1 aaa
2 bbb
3 ccc