Handle too-short write(3)s in mod_json_cdr

write(3) can write fewer bytes than was requested for any number of
reasons.  The correct behavior is to retry unless there is an error.

If there is an error, try to unlink the file; no sense in leaving
corrupted data laying around.
Output newline after json output in mod_json_cdr

In UNIX, text files by definition end with a newline.