Basically all you have to do is set a counter. I assume you're reading the contents of your file in a loop, right? Before the loop do something like:
int counter = 10;
while ( FILE_READ_CONDITIONS && counter>0) {
// etc
counter--;
}
Or you could put a counter-- in the while conditions if you like.