use finished to avoid fd leak in stream-file