> For the complete documentation index, see [llms.txt](https://trizen.gitbook.io/sidef-lang/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://trizen.gitbook.io/sidef-lang/programming_tasks/r/remove_lines_from_a_file.md).

# Remove lines from a file

```ruby
func remove_lines(file, beg, len) {
    var lines = file.open_r.lines
    lines.splice(beg, len).len == len || warn "Too few lines";
    file.write(lines.join("\n"), :utf8)
}

remove_lines(File(__FILE__), 2, 3)
```
