perf1: don't close the file in critical section