fmt.Print and friends (fmt.Println and fmt.Printf) write to os.Stdout.
So you're already writing your results out:
out, _ := json.MarshalIndent(e, "", "")
fmt.Println(string(out))
You might consider writing error messages to standard error so they don't get confused with standard out:
fmt.Fprintln(os.Stderr, "Cannot read the file or file does not exists")
os.Exit(1)
how you redirect to to a file?
When you run your program you can specify a redirect in the shell:
go build
./my-program > results.txt
The shell will open results.txt O_CREAT|O_TRUNC and connect that open file to your program's standard output stream. In this case, you won't see the standard output on the terminal because it's going into the file instead.
If you want to see the standard output that's being read to a file, you can pipe the output to tee instead of a file:
./my-program | tee results.txt
tee is a program the reads its standard input, and writes it to both its standard output and the specified file. In that invocation, the shell creates a pipe, connects the pipe's input end to my-program's standard output, and connects the pipe's output to tee's standard input before executing my-program and tee.
This way you can create a "pipeline" of commands, using the output of one as the input of the next, to describe complex tasks as a combination of simple operations. By writing to stdout in your programs, you give the user control over exactly what stdout is.