you will get endless loop if the input isn't integer.