public static function toFile(Stringset $set, $filename)
    {
        try {
            $str = self::toString($set, $options);
            if (!file_exists($filename) || is_writable($filename)) {
                file_put_contents($filename, $str);
            } else {
                throw new Exception("Cannot write to file");
            }
        } catch (\Exception $e) {
            throw $e;
        }
    }