I got it working now. Had to change the fopen to be binary and not text.
Here's a quote from the php manual which I didn't notice the first time I checked
"If you do not specify the 'b' flag when working with binary files, you will experience strange problems with your data, including broken image files and strange problems with \r\n characters.
It is strongly recommended that you always use the 'b' flag when opening files with fopen(). "
Here is my working code:
$file = fopen($filename, "wb") or die("failed to open $filename");
fwrite($file, "\r\n$rowLabel[$i],$c1[$i],$c2[$i]") or die("failed to write row to file");
Note: I only changed the endline to the beginning of the statement for formatting reasons.