Question: I have already understood the Horner's scheme for one variable polynomials like (2x^3+x+1) but I have not found a clear explenation for the two variable polynomials like (2x^6+3y+9) and i want to create a program in java to calcualte the scheme for me.

Answer: 
First add the following usings so you don't need to type out the entire namespaces for everything.

```
using System.Text.RegularExpressions;
using System.IO;

```

The reason it doesn't work is because `File.WriteAllLines` expects a `IEnumerabl<string>` or a `string[]`, but you're passing a `string`. Either use `File.AppendAllText` or just call `File.WriteAllLines` once after the `foreach` like this.

```
var lines = new List<string>();
foreach (string ss in fileLines)
{
    lines.Add(Regex.Replace(ss, @"\s+", " "));
}
MessageBox.Show("ok");
File.WriteAllLines(@"C:\Users\Public\WriteLines.txt", lines);

```

Or like this using Linq

```
File.WriteAllLines(
    @"C:\Users\Public\WriteLines.txt",
    fileLines.Select(ss => Regex.Replace(ss, @"\s+", " "));

```

But based on some of your comments you might want to do the following

```
File.WriteAllLines(
    @"C:\Users\Public\WriteLines.txt",
    File.ReadLines(@"InputPath")
        .Select(ss => Regex.Replace(ss, @"\s+", " "));

```

Because of lazy initialization that will read in each line of your input file one at a time, do the regular expression replacement then write the line out before moving to the next line. That will be scale-able if you need to run this on a very large file as it does not require the entire file to be in memory at one time.
I am not sure about your requirement but it seems you are trying to use string in place of collection. This code may help.

```
List<string> lines = new List<string>();
foreach (string ss in fileLines)
{
   string filelinesclean = System.Text.RegularExpressions.Regex.Replace(ss, @"\s+", " ");
   lines.Add(filelinesclean);
}
System.IO.File.WriteAllLines(@"C:\Users\Public\WriteLines.txt", lines);

```

I have keep your code as it is and added/updated few lines.