I am creating a system which involves the creation of a CSV for error logging.

My current code successfully creates a new file with a unique name, then adds the existing data (from an array) into the CSV. The problem I'm having is adding new lines into the file, which is required to maintain proper structure. 

My existing code:

```
$current = file_get_contents($fileName);
foreach($error as $err) {
    foreach($err as $title => $info) {
        $current .= $info . ',';
    }
    $current .= "\n";
}
file_put_contents($fileName, $current);

```

A `var_dump` of my array structure for `$error` is as follows:

```
array (size=3)
  0 => 
    array (size=4)
      'id' => string '1' (length=6)
      'name' => string 'Kyle Katarn' (length=19)
      'qty' => string '1' (length=3)
      'date' => string '' (length=0)
  1 => 
    array (size=4)
      'id' => string '2' (length=6)
      'name' => string 'Dash Rendar' (length=23)
      'qty' => string '1' (length=2)
      'date' => string '' (length=0)
  2 => 
    array (size=4)
      'id' => string '3' (length=6)
      'name' => string 'Mara-Jade' (length=24)
      'qty' => string '1' (length=2)
      'date' => string '' (length=0)

```

I have looked on various different SO questions, and none has resolved this issue. Any help would be appreciated.