diff --git a/ini.go b/ini.go index 29f8d63..a94cd89 100644 --- a/ini.go +++ b/ini.go @@ -102,9 +102,7 @@ func Write(writer io.StringWriter, entries []Entry) error { for _, entry := range entries { if entry.Section != section { - section = entry.Section - - if _, writeError := writer.WriteString("["); writeError != nil { + if _, writeError := writer.WriteString("\n["); writeError != nil { return writeError } @@ -112,9 +110,11 @@ func Write(writer io.StringWriter, entries []Entry) error { return writeError } - if _, writeError := writer.WriteString("]"); writeError != nil { + if _, writeError := writer.WriteString("]\n"); writeError != nil { return writeError } + + section = entry.Section } if _, writeError := writer.WriteString(entry.Key); writeError != nil {