in reply to while loop hanging
a) This has the look of homework.
b) The second while loop is not hung, it is trying to read from standard input. The magic <> operator consumes @ARGV, you see.