Fixing bug where output file would be written to source rather then current directory