I've just run your script fragment on a Win98SE machine and the output is interesting, to say the least. Have a look at the flavor line.

Kernel is Win9x
OS is Win98
Flavor is $flavor

Oh, the script did also bomb out with the machine being identified, incorrectly, as a server.

Ok, here's the cause:
The subversion for 98SE is " A " (<space>A<space> ). Change that and the script works as expected. Better yet, fill in the $subver variable with a default string at the head of the script to ensure it is never empty when you get to the bottom, which is the real reason the script failed.