int main(int argc, char **argv)
{
    FILE *fp;
    char *buf;
    size_t sz;
    int start, count, lines = 1;
    int dest = 0, src = 0, pos = -1;

    
    if (argc != 4)
        ERROR(, argv[0]);

    if ((count = atoi(argv[3])) < 1) 
        return 0;

    if ((start = atoi(argv[2])) < 1)
        ERROR(, start);

    if ((fp = fopen(argv[1], )) == NULL)
        ERROR(, argv[1]);

    
    fseek(fp, 0, SEEK_END);
    sz = ftell(fp);
    buf = malloc(sz + 1);
    rewind(fp);

    
    while ((buf[++pos] = fgetc(fp)) != EOF) {
        if (buf[pos] == '\n') {
            ++lines;
            if (lines == start) dest = pos + 1;
            if (lines == start + count) src = pos + 1;
        }
    }

    
    if (start + count > lines) {
        free(buf);
        fclose(fp);
        ERROR(, --lines);
    }

    
    memmove(buf + dest, buf + src, pos - src);

    
    freopen(argv[1], , fp);
    fwrite(buf, pos - src + dest, 1, fp);

    free(buf);
    fclose(fp);
    return 0;
}