add option to create and close files