I am opening a particular directory and then reading the files in it one by one(while loop) and some validation is done for each file and for a particular condition the file is deleted from the directory and another file which is a pair of this (eg: buy.x.txt and sell.x.txt)is also deleted with this,so that in the readdir iteration,this pair file is not taken for validating again in the loop. but my problem is that, even though i am deleting(unlink) the pair file, it is taken for reading in the next iteration of while loop. How can i avoid this problem?