DatasetManager.saveToFile function implementation