code refactored. _generateOutputFile private function added.