fixes unclosed file handles building up
fixes 100 percent cpu utilization