safer reading of json stream from a file