fixed bugs with opening and saving files