Hi everybody thanks but i got over the problem, since i found out that as soon as it comes out of the first while loop the counnter of that while loop becomes zero when it is not iterating. So i have put up a case that if the counter becomes zero then only take the value otherwise dont.