Replaced panic()'s with log.Fatalf()
Simplified opening and creating the output file