You can for example use the following pattern to read until your termination byte:
r := bufio.NewReader(conn) for { yourLine, err := r.ReadBytes(10) ... write your file ... }
Similar there is also r.ReadString('\n')
which would too.