trimming white space, making a while loop