Fixed null ptr exception on login

the for loop was causing null pointer exception if username or password
was incorrect- while loop fixes this.