Close input files when finished with them
Correctly handle case of having fewer rules to prune than desired number