merged adhitya's file truncation fix. removed extra printfs