Close old file and open new one