debug
flush when done
calculate total files first