Improved the while's logic in increment_active_files().