I am new to working with System.IO.

I have an application that grabs a Json file from the web and only grabs partial data to display on the Windows Application Form's controls.
The form allows the user to save the data as a new file and load a file if ONLY it contains the "indicator" I added in when the file was saved that tells the program it was saved by my program.

Everything works.

Whenever a file that doesn't contain that indicator is loaded to the program, it doesn't show nothing which is what I want it to do, but I also want a Messagebox.Show() to pop up and let the user know why the values are empty and why nothing happened.

```
if(openFile.ShowDialog() == DialogResult.OK)
{
    string dataLine = string.Empty;
    using (StreamReader read = new StreamReader(File.OpenRead(openFile.FileName)))
    {

        dataLine = read.ReadToEnd();
        string[] beginningOfData = dataLine.Split(',');
        string temporary = string.Empty;
        foreach (string line in beginningOfData)
        {
             //Indicator
             if(line.Contains("Indicator")
             {
                temporary = line.substring(9);
                //Goes through the rest of the file
                //Converts data to control value and adds it
             }
             else
             {
                //Where I tried to display the message box       
             }
        }
    }

}

```

This what I've tried, but it wasn't working as I wanted it too

```
else
{
    MessageBox.Show("Can't load data.");      
}

```

It would still show the MessageBox even if it read that the indicator was there and displayed the data inside the corresponding controls. Also whenever I tried to close the MessageBox it would just show it again.

So I decided to this instead:

```
else if(!line.contains("Indicator"))
{ 
    MessageBox.Show("Can't load data.");
    break;
}

```

and in this way too:

```
else
{
    if(!line.contains("Indicator")) 
    { 
        MessageBox.Show("Can't load data.");
        break;
    }
}

```

I also tried making it more specific by doing 

```
if(line.contains("Indicator") == false)
{
   //Code here
}

```

But it would still display it even if the file was created by the program.

The break; did stop the message box from re-appearing again, but I only want the MessageBox to show when it's the incorrect text file (not containing the indicator) and allow me to close the MessageBox to try again.