shouldn't it be netWithoutSpaces.length != 0 ?