improve json output

This solves two problems with json:
1) when you read a trace from a file, the terminator ']' is not inserted
2) on live capture the last event is not printed until you quit sysdig or another event is printed