Added lines to close the file and erase it.