fixed the bug
added break on end of input