From 64224e7caaad745f988c7e153f74a5b5bf2e5077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luka=20Marku=C5=A1i=C4=87?= Date: Wed, 3 Aug 2022 13:57:26 +0200 Subject: [PATCH] Update pkg/commands/oscommands/os.go Co-authored-by: Ryoga --- pkg/commands/oscommands/os.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/commands/oscommands/os.go b/pkg/commands/oscommands/os.go index 5f89f976f..2a7cc1328 100644 --- a/pkg/commands/oscommands/os.go +++ b/pkg/commands/oscommands/os.go @@ -120,17 +120,17 @@ func (c *OSCommand) AppendLineToFile(filename, line string) error { return utils.WrapError(err) } - buf := make([]byte, 1) if info.Size() > 0 { // read last char + buf := make([]byte, 1) if _, err := f.ReadAt(buf, info.Size()-1); err != nil { return utils.WrapError(err) } - } - // if the last byte of the file is not a newline, add it - if []byte("\n")[0] != buf[0] { - _, err = f.WriteString("\n") + // if the last byte of the file is not a newline, add it + if []byte("\n")[0] != buf[0] { + _, err = f.WriteString("\n") + } } if err == nil {