out should be null after writing