# gets with two arguments returns the length of the line,
# -1 if the end of the file is found
#
while { [gets $infile line] &gt;= 0 } {
    incr number
}
close $infile

puts "Number of lines: $number"

#
# Also report it in an external file
#
set outfile [open "report.out" w]
puts $outfile "Number of lines: $number"
close $outfile
</pre>

<div class="nav"><a href="Tcl23a.html">Previous lesson</a> | <a
href="tcltutorial.html">Index</a> | <a href="Tcl25.html">Next
lesson</a></div>
</body>
</html>



			<asid