modified distance-checker( add file-output mode )