Exit optional loop when argument is found