Reduce frequency of file opening/closing