in reply to optimization in file processing

You are far more likely to get useful answers if you post your script so we can see exactly what you are doing.