diff --git a/kg/helpers.go b/kg/helpers.go index 043c01c..1786cbc 100644 --- a/kg/helpers.go +++ b/kg/helpers.go @@ -32,13 +32,21 @@ func genRange[T character](start, end T) []T { } // Returns whether or not the given file contains a NULL character -func fileContainsNullChar(file *os.File) bool { +func fileContainsNullChar(filename string) (bool, error) { + file, err := os.Open(filename) + if err != nil { + return true, err + } + defer file.Close() scanner := bufio.NewScanner(file) for scanner.Scan() { line := scanner.Text() if strings.Contains(line, "\000") { - return true + return true, nil } } - return false + if err := scanner.Err(); err != nil { + return true, err + } + return false, nil }