Generate /* line number comments */ Your task is to write a program (or function) that will take a string as input and append text to the beginning of every line that satisfy the following rules:


The text appended must contain the line number. You may use 0- or 1-based indexing.
The text must be a comment in your language. A comment is defined as a syntacticly valid piece of code that makes no changes to the program's state. Removing the comment should make no change to the program.
The comment may
only contain newlines at the end of it.
You do not have to put line numbers for lines that contain just whitespace and comments.


Specifications


You may assume that the input will be a valid program in your language.
In indentation-sensitive languages like Python, you may place the line number comment after all indentation. You may choose either tabs or spaces to be your indentation character, but you must specify on your post.
You may assume that every statement in the code will take up at most the entirety of 1 line; i.e. no multi-line strings or backslash-continuation.


Test Cases

Python:

#0
a = int(input())
#1
while a:
    #2
    print(a)


C: (Honestly, I'm surprised this compiles)

/*0 */#include &lt;stdio.h&gt;
/*1 */int main()
/*2 */{
/*3 */    char c;
/*4 */    c = getchar();
/*5 */    do
/*6 */    {
/*7 */        putchar(c);
/*8 */    }
/*9 */    while (c);
/*10*/}


This is code-golf, so the shortest answer (in bytes) wins.
Perl, 8+1 = 9 bytes

say"#$."


Run with -p (1 byte penalty). (Note to people unfamiliar with PPCG rules; you also need to specify a modern version of Perl syntax using -M5.010, but we decided that options to select language versions are free and don't incur a byte penalty, so I didn't mention it in the original version of this post.)

-p places the program into an implicit loop; it basically causes the program to become a filter that processes each line separately (i.e. the entire program is run on the first line, then the second, then the third, and so on). Perl also keeps track of a line number, called $., that records how many lines of input have been read. So all the program's doing is letting -p read a line of input; output a #, the current line number ($.), and a newline (say adds a newline by default, which is helpful in this case, and is also shorter than the more commonly seen print); and then letting -p output the original line of code that it read (typically a program using -p would do some sort of processing on the input, but because we didn't, it's just output unchanged). Comments in Perl run from # to a newline (the # in the program itself doesn't start a comment because it's inside a string literal), so what we're basically doing is taking the opportunity to write comment lines into the file as we process it, without disturbing the "natural" read and write cycle of -p.