This will fail if folder starts with ".", example "/home/kd/.certs/abc.pfx"
You can remove extension from reverse, something like: "/home/kd/.certs/abc.pfx".sub(/\.(\w+)$/,'')

Also, config[:output_file] has default value, so if check wont be needed.