How would I delete a specific line in a file

Here is quick and dirty example:

const std = @import("std");

fn help(prog: []const u8) void {
    std.debug.print (
        "usage: {s} <line-number-to-skip> < input-file > output-file\n",
        .{prog}
    );
}

pub fn main() !void {

    const prog = std.mem.sliceTo(std.os.argv[0], 0);

    if (std.os.argv.len != 2) {
        help(prog);
        return;
    }

    const lnstr = std.mem.sliceTo(std.os.argv[1], 0);
    const ln = try std.fmt.parseInt(u32, lnstr, 10);

    var i = std.io.getStdIn();
    var is = i.reader();

    var o = std.io.getStdOut();
    var os = o.writer();

    var buf: [1024]u8 = undefined;
    var cnt: u32 = 0;
    while (try is.readUntilDelimiterOrEof(&buf, '\n')) |line| {
        cnt += 1;
        if (cnt == ln) continue;
        _ = try os.write(buf[0..line.len]);
        _ = try os.write("\n");
    }
}
$ cat a.txt 
111
222
333
444
555
666
777
888
999
$ ./skip-line 3 < a.txt > b.txt
$ cat b.txt 
111
222
444
555
666
777
888
999

EDIT:
By some reason

os.write(line);

does not work (zero output file size)

(
but
std.debug.print(line) works!!!
)

so I used

os.write(buf[0..line.len]);