---
title: "Delete the first line of a text file without reading it"  
description: "Delete the first line of a text file without reading it"  
author: "marcel ethan"  
published: 2014-01-30  
updated: 2014-01-30  
canonical: https://www.mindstick.com/forum/1920/delete-the-first-line-of-a-text-file-without-reading-it  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Delete the first line of a text file without reading it

I'm working with a very [large](https://www.mindstick.com/interview/34471/what-is-a-large-language-model-llm) [text file](https://www.mindstick.com/forum/12828/converting-a-text-file-to-an-array-in-java) (around 70 thousand lines) and I want to [remove](https://yourviews.mindstick.com/story/4554/8-harmful-weeds-to-remove-from-garden) the top line.

Clearly, loading the entire thing into [memory](https://www.mindstick.com/blog/300050/what-causes-sudden-memory-loss), deleting the top line, then re-[writing](https://www.mindstick.com/articles/12997/5-essential-tips-on-resume-writing-for-business-analysts) the whole thing again is inefficiant:

[var](https://www.mindstick.com/forum/33920/what-is-different-var-and-dynamic-types-in-c-sharp) lines = File.ReadLines(accountFileLocation.Text).Skip(1);

File.WriteAllLines("output.txt", lines);

Is there any other way to do it?

## Replies

### Reply by Pravesh Singh

Hi Marcel,\
Try this:\

List lines = [File](https://www.mindstick.com/articles/59/encrypting-and-decrypting-files-using-c-sharp).ReadAllLines(Filename).ToList(); And remove the [0] index from the list create file again

File.WriteAllLines(Filename, lines.ToArray());


---

Original Source: https://www.mindstick.com/forum/1920/delete-the-first-line-of-a-text-file-without-reading-it

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
