store output to a file and read from it

Hello all,
I need to run snoop command for a period of time (a day) and extract remote host column from it to find out who is accessing my server. When I run the following on the command line it works
snoop -port 22 | awk '{print $3}'
but when I do
snoop -port 22 | awk '{print $3}' | while read hname;do echo $hname;done
it does not work. I need to caputre the outbound hostnames and do some testing on them. Any idea would be much appreciated


for hname in `snoop -port 22 | awk '{print $3}' `
do
     echo $hname
done > outputfile

Jim thanks for the input but, it is not working. I do not get anything in the output file