Fix out file may not clean in case of error