First, DO NOT USE GOTO! There's absolutely NO REASON the code you posted needs to have GOTO statements. Write proper code. I haven't used a GOTO since 1978. It's a hold-over from interpreted basic, and should be avoided at all costs.
Second, here's my version of your method (assuming I have correctly determined what you're trying to do).
private static void button21_Click(object sender, EventArgs e)
string line = string.Empty;
StringBuilder text = new StringBuilder();
List<string> fileContent = new List<string>();
int lineCounter = 0;
using (StreamReader sr = new StreamReader(@"c:\temp\Input.txt"))
if (fileContent.Count > 0)
line = fileContent[lineCounter];
} while ((lineCounter < fileContent.Count) &&
(lineCounter <= 5 ||
line.Contains(" End") ||
using (TextWriter sw = File.CreateText(@"c:\temp\Output.txt"))
catch (Exception ex)
string error = string.Concat(ex.Message,