Added saveToFile functions