Improved the performance of getNextFile() when there are thousands of files in spoolDirectory.