Fixed directory changes when saving files