func saveIndex(index *structs.Index, fileName string) error {
	f, err := os.Create(fileName)
	if err != nil {
		return err
	}

	encoder := gob.NewEncoder(f)
	err = encoder.Encode(structs.IndexToGobIndex(index))

	return err
}
// Copy-paste-hacked from sampleclient.go.
func saveIndex(index *structs.Index, w io.Writer) error {
	encoder := gob.NewEncoder(w)
	err := encoder.Encode(structs.IndexToGobIndex(index))
	return err
}