Hi Ikegami ,
Yes it gives me answer . But the thing is it is also taking the white spaces and also assign them the IP address.
i mean it also take the blank lines into consideration
It doesn't take blank lines into consideration because you didn't mention the possibility of blank lines. Inserting the following at the start of the loop will solve that problem.