fix the bug when file not trunced
improve output log and fix offset bug
fix a critical bug and improve code style