in reply to While Loop Problem!

This is an architectural comment -- so take it with a pinch of salt.

You should think about separating the presentation layer (printing out HTML) from your business logic. In this example, I would have the subroutine (if that's what this fragment is) return $line, which would be either a valid value or undef. Up above, the caller routine would decide what to output.

Following on that idea, think about using the excellent CGI module for outputting HTML using an OO approach rather than printing raw HTML.

--t. alex
Life is short: get busy!