Is this a bug or a limitation?

Hi,

I'm having a problem with a while loop syntax that doesn't seem to loop correctly.

TODAY=`date +%d%m%Y`
while read hostname
#for hostname in $(cat $CONFIG)
do
OUTFILE=/tmp/health_check.$hostname.$TODAY

if [ ! -f $OUTFILE ]
then
touch $OUTFILE
func_header
else
rm $OUTFILE
func_header
fi

funcCheckIP # Calls a function

print
print " *** Automated Health Check on host $hostname completed *** "
print
print "** A summary of each checks have been written to a logfile."
print "** The logfile is located at $OUTFILE"
print "** Take note that the logfile does not contain any details of any errors"

done < $CONFIG

$CONFIG is a file (/tmp/hosts.name) where the contents are:
redang
tioman
sipadan

The wierd part is, when I played around by:

1) removing the calling function and replace it with a "print $hostname" all hosts are printed correctly.
2) replacing the while loop with "for hostname in $(cat $CONFIG)", all hosts are called properly.

Is there a limitation of a function calling another function and the number of loops allowed within the parent loop? Or am I making any sense at all? Any pointers are appreciated.

Hard to say with the sparse details you provided. But you're probably redefining stdin. Each process only has one stdin and your
while read var ; do
done < inputfile
has used it up.

Next time at least tell us which shell you are using. Some shells have different kinds of functions so seeing how the function is defined would be a big help here. The OS would be nice too.

Sorry mate.

I'm using Solaris 8 and the script is written in Korne Shell.