@agama
I can't try your code because I don't have sed -i but the code looks good and efficient.
Reading between the lines the O/P posted code which should remove a line from a file one-line-at-a-time until it reached the required number of lines. Obviously an academic (or homework?) problem because there are much easier ways of achieving the final result, but agama's solution is really good.
@Methyl -- It seemed a waste starting n-10 processes just to remove the first line of a file. I didn't do any experiments, but with the -i option I would assume that sed then writes n-1 lines to a tmp file and does a rename. That's lots of I/O that isn't necessary since it can be done with just two passes.
I tend not to use -i, as you point out it's less portable, and if writing for greater portability (assuming modern shell) might do it this way: