My guess is that those last two lines are caused by trying to map to blank printers. For example if an empty line is at the end of your printer.ini file, it will still be read and will return a vartype of 8, but of course will fail because its blank. I would replace the entire Vartype check with a Len check to verify that it actually contains data.

Maybe change both of the lines from this...
 Code:
IF VARTYPE($printer) = 8
To something like this...
 Code:
IF LEN(TRIM($printer))>0

This will trim all leading and trailing space, and then verify that its still atleast 1 char long.