Added input validation to saveFile