close stream and file after test for repeatable test