Every time you evaluate <STDIN> you read a line from standard input. That means the first if() looks at the first line then the second if() looks at the next one, etc. Probably not what you meant! Instead, assign <STDIN> to a variable and then you can test it against multiple conditions.
-sam