fix bug in file handle