Adding close after the writing