cleanup and test for file.contents being a stream