Added close file in WriteYaml

This will fail on windows if the file is still open when renaming
you can do as @bz2 suggested:
```go
_, err = f.Write(data)
// We close here instead of using a defer because windows will complain if we
// try to move a file which is open.
f.Close()
if err != nil {
    return err
}
return ReplaceFile(prep, path)
```