diff --git a/client/commands/seeds/export.go b/client/commands/seeds/export.go index babd1748a6..b37c11bfb0 100644 --- a/client/commands/seeds/export.go +++ b/client/commands/seeds/export.go @@ -48,16 +48,12 @@ func exportSeed(cmd *cobra.Command, args []string) error { } func writeSeed(seed certifiers.Seed, path string) (err error) { - var f *os.File - f, err = os.Create(path) - if err == nil { - stream := json.NewEncoder(f) - err = stream.Encode(seed) - f.Close() - } - // we don't write, but this is not an error - if os.IsExist(err) { - return nil + f, err := os.Create(path) + if err != nil { + return errors.WithStack(err) } + defer f.Close() + stream := json.NewEncoder(f) + err = stream.Encode(seed) return errors.WithStack(err) }