only close file when transfer is confirmed complete