fix issue where json would be printed to stdout even though outF is another file
While we are at it, removed unnecessary global declarations and add what I presume were missing return statements
Since I am unsure how to properly test these things I submit it for review.