Processing multiple drag and dropped files fails when using regular expressions
<p>In my application the user can drag and drop multiple text files onto a GUI control to convert them to another format. Here is the relevant code: </p>

<pre><code>    private void panelConverter_DragDrop(object sender, DragEventArgs e)
    {
        string[] filenames = (string[])e.Data.GetData(DataFormats.FileDrop);
        foreach (string filename in filenames)
        {
            convertFile(filename);
        }
    }

    private void convertFile(string filename)
    {
        // build name of output file
        string convertedFile = Path.ChangeExtension(filename, ".out");

        // open input file for reading
        FileInfo source = new FileInfo(filename);
        StreamReader srcStream = source.OpenText();

        // open output file for writing
        StreamWriter dstStream = new StreamWriter(convertedFile);

        // loop over input file
        string line;
        do
        {
            // get next line from input file
            line = srcStream.ReadLine();

            if (!Regex.IsMatch(line, @"fred=\d+"))
            {
                dstStream.WriteLine(line);
                dstStream.Flush();
            }
        } while (line != null);
    }
</code></pre>

<p>The problem is that when I drop multiple files on the GUI, only one of them actually gets processed. I have found that if I comment out the Regex line, all of the dropped files are processed. Am I missing something in my handling of regular expressions in this context?</p>
