errors while using getline

i wrote following script to test getline

 
BEGIN{
 while ( "who" | getline > 0)
 nr++
 print nr
}
 

when i run this script as

 
 awk -f scriptname
 

i get the following output

 
awk: syntax error near line 2
awk: illegal statement near line 2

please let me know what is going wrong:confused:

as always...... if on Solaris use /usr/bin/nawk or /usr/xpg4/bin/awk

Thanks vgersh99