Fix bug where saving to wrong file.