Removed separate loop for EndOfInput