Made rewrite open when main file is opened