insert multiple json to a txt file in php

$json = {"id":"1:","food":"apple","color":"red"}{"id":"2:","food":"manggo","color":"yellow"}

I have a json like the one above and mycode

file_put_contents('json.txt', $json);

My question is why the one that goes to the json.txt file is just one json?

I have code like this

foreach($json as $element) {
    $array = array( 'ID' => $element->id, 'FOOD' => $element->food, 'COLOR' => $element->color, );
    $out = print_r($array, true);
    file_put_contents('json.txt', $out);
}