You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: util.go
    path of file: ./repos/ascii-image-converter/aic_package
    
    the code of the file until where you have to start completion: /*
Copyright Â© 2021 Zoraiz Hassan <hzoraiz8@gmail.com>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package aic_package

import (
	"fmt"
	"io/ioutil"
	"os"
	"os/exec"
	"path"
	"runtime"
	"strings"

	imgManip "github.com/TheZoraiz/ascii-image-converter/im
    
func saveAsciiArt(asciiSet [][]imgManip.AsciiChar, imagePath, savePath, urlImgName string, onlySave bool) error {
	// To make sure uncolored ascii art is the one saved as .txt
	saveAscii := flattenAscii(asciiSet, false, true)

	saveFileName, err := createSaveFileName(imagePath, urlImgName, "-ascii-art.txt")
	if err != nil {
		return err
	}

	savePathLastChar := string(savePath[len(savePath)-1])

	// Check if path is closed with appropriate path separator (depending on OS)
	if savePathLastChar != string(os.PathSeparator) {
		savePath += string(os.PathSeparator)
	}

	// If path exists
	if _, err := os.Stat(savePath); !os.IsNotExist(err) {
		err := ioutil.WriteFile(savePath+saveFileName, []byte(strings.Join(saveAscii, "\n")), 0666)
		if err != nil {
			return err
		} else if onlySave {
			fmt.Println("Saved " + savePath + saveFileName)
		}
		return nil
	} else {
		return fmt.Errorf("save path %v does not exist", savePath)
	}
}