Added code to handle and optional 3rd argument for output file path

Hi there.

Added code to handle and optional 3rd argument for output file path

Cheers,
Nigel.