What is the necessity of checking condition here? OK, nothing wrong done here.
You don't need to set flag=0 here in this condition you could use it in LINE number 21.