do not close file resource too early