write and delete the input stream to tmpfile