Extreme beginner experiencing problems with reading files

From: James Roberts (James.W.Roberts5_at_boeing.com)
Date: 02/27/04


Date: Fri, 27 Feb 2004 20:18:36 GMT

I am an extreme beginner to all of Tcl/Tk and stumbled upon this so maybe
some of the experts here can help get a newb started.

I'm writing a simple Tcl script that parses file, checks for a specific tag
in the file and then outputs that tag.
My code goes something like

set FileList [GrabFiles /home]
foreach File $FileList {
    set InFile [open $File r]
        while {[gets $InFile line] != -1} {
            if {[string first "<BODY>" $line] != -1} {
                rest of code

My problem is when it gets to the

while {[gets $InFile line] != -1} {

it returns

can not find channel name "file3"

why can it not find that channel? The file is still open and it's opened for
read in the line directly before the while statement?

Any help from the Tcl/Tk experts out there?