Optimization while(true) -> while(hasNext)