Fix crash when writing to relative paths.