nl2br() changes "\n" to "<br />\n"
That is the desired behavior ("<br />" being a valid HTML 5.0 aka XHTML 1.0 element).
In 99% of cases, this is the function to use for converting newline characters to HTML line breaks - because 99% of the time, leaving the newline character in there improves code readability and doesn't really matter.
In your case, where you are saving to a text file, you don't want the newlines left in. So you should use str_replace("\n", nl2br($myString)).
Don't use ereg_replace() or eregi_replace() for something as trivial as stripping new lines. Use str_replace(), which doesn't have the overhead of a regex engine.
Mike