awk getting stuck after BEGIN

I am beginner in awk

awk 'BEGIN{for(i=1;(getline<"opnoise")>0;i++) arr[i]=$1}{print arr[20]}'

In the above script, opnoise is a file, I am reading it into an array and then printing the value corresponding to index 20. Well this is not my real objective, but I have posted this example to describe the problem.

The problem is when I execute the script there is no activity(no error, just a blank) and the body i.e, the print statement, execute only when I hit "ENTER" for the second time. Also gawk does not exit to command prompt automatically, I have to hit CTRL+C to exit and awk gets displayed while exiting.

Here is what happens,

user@server ~/folder
$ awk 'BEGIN{for(i=1;(getline<"opnoise")>0;i++) arr[i]=$1}{print arr[20]}'

684
awk

user@server ~/folder
$

Actually this what I am trying to do. I need to use the values in the array to remove certain records in file opwflightno and make a new file opwonoise. But awk is not executing beyond BEGIN. I had posted above simple example to describe the problem.

awk 'BEGIN {for(i=1;(getline < �opnoise�)>0; i++) arr=$1}{for(j=1; j<=i; j++){if(arr[j]!=$1){print $0}}}' opwflightno > opwonoise

Bumping up posts or double posting is not permitted in these forums.

Please read the rules, which you agreed to when you registered, if you have not already done so.

You may receive an infraction for this. If so, don't worry, just try to follow the rules more carefully. The infraction will expire in the near future

Thank You.

The UNIX and Linux Forums.