Hi, why every character that is received is saved in a new line in the file

f, err := os.Create(“lines”)
if err != nil {
fmt.Println(err)
f.Close()
return
}
for {

                            var r [10]rune
                            var s string
                            var poo int = 1
                            poo=poo+1
                            fmt.Scanf("%c",&r[poo])
                            s = fmt.Sprintf("%c", r[poo])
                            d := []string{s}

                            for _, v := range d {
                                    fmt.Fprintln(f, v)
                                    if err != nil {
                                            fmt.Println(err)
                                            return
                                    }
                            }

Because you use Fprintln which appends a newline to the string when writing.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.