modify for ... in & if hasOwnProperty to _.each
write output to file; don't use _.each