Fix delete file & infinite loop