That's becuase you have an assignment operation as your sentinel, and assignments always return true. Assignments in sentinals are a giant anti-pattern
I suspect you're trying to do this:
var fileCounter = 1;
var lineCounter = 0
var destiNationFile = new StreamWriter(string.Format(destinationFileName, fileCounter));
foreach(var bank in BankAcoutNumbers.BANS.Take(200))
{
if(lineCounter % linesPerFile == 0)
{
destiNationFile.Flush();
destiNationFile.Dispose();
destiNationFile = new StreamWriter(string.Format(destinationFileName, fileCounter));
fileCounter++;
}
destiNationFile.WriteLine(bank);
lineCounter++;
}
Oh, and then you dispose of it in the loop, which is bad juju since your break condition now no longer exists in memory. Use a recursive function for this, not a while loop.
The while loop looks to be meaningless, so here's a more concise copy.