Fixed logic with output file path, in case input file has a path included