UNIX File handling -Issue in reading a file

I have been doing automation of daily check activity for a server, i have been using sqls to retrive the data and while loop for reading the data from the file for several activities. BUT i got a show stopper the below one.. where the data is getting store in $temp_file, but not being read by while loop. can anyone help in this..wots wrong with this.

TEMP_FILE=store.tmp
sqlplus -s ${DB_USER}/${DB_PASS}@${DB} > $TEMP_FILE <<EOF
        set pages 0
        set line 120
        SET FEEDBACK OFF
        SELECT username,machine,count(*)as sessions FROM v\$session WHERE status='INACTIVE' GROUP BY username,machine;
        exit; #this is storing result perfectly in file $TEMP_FILE
  EOF
        {
         while read rec; do
         #if [ "${rec}" != "" ] ; then
        echo "line is :$rec"       # nothing is coming (reading)
        usern=`echo $rec|awk '{print $1;}'`
        mach=`echo $rec|awk '{print $2;}'`
        sesn=`echo $rec|awk '{print $3;}'`
        echo "$usern : $mach: $sesn" # nothing is coming
          #fi
        done } < $TEMP_FILE

#Running with set -x /set -v output is as follows

+ sqlplus -s user/pa55word@myDB
+ 1> store.tmp 0<<
        set pages 0
        set line 120
        SET FEEDBACK OFF
        SELECT username,machine,count(*)as sessions FROM v$session WHERE status='INACTIVE' GROUP BY username,machine;
        exit;
  EOF
        {
         while read rec; do
         #if [ "" != "" ] ; then
        echo "line is :"
        usern=+ awk {print $1;}
+ awk {print $1;}
+ echo
+ echo
 mach=+ awk {print $2;}
+ awk {print $2;}
+ echo
+ echo
        sesn=+ awk {print $3;}
+ awk {print $3;}
+ echo
+ echo

It's this line:

  EOF

Should not have an indentation:

EOF

It's quite interesting that the "-s" (silent) switch to sqlplus has hidden the fact that half your script went into the sql program! The sql interpreter stopped looking when is saw "exit".