```
package main

import (
"bufio"
"log"
"os"
)

func main() {
f, err := os.OpenFile("1.txt", os.O_RDWR, 0666)
if err != nil {
log.Fatal(err)
}
defer f.Close()
delim := "\n"
var offset int64
r := bufio.NewReader(f)
for {
offset--
_, err := f.Seek(offset, os.SEEK_END)
if err != nil {
log.Println(err)
break
}
r.Reset(f)
b, err := r.Peek(1)
if err != nil {
log.Println(err)
break
}
if string(b) == delim {
break
}
}
info, err := f.Stat()
if err != nil {
log.Fatal(err)
}
err = f.Truncate(info.Size() + offset)
if err != nil {
log.Fatal(err)
}
}

```