close the file IO before transfering.