Switch from Shellwords.escape call to quoting when saving file to fix saving on windows

Using Shellwords.escape leads to failure on windows systems which don't use the same escaping rules as unix. Instead opt to quote strings which should work on both systems (and escape quotes with a backslash).