implemented saveFile functionality