Based on TR feedback

1. encode to UTF 8 before file write.
2. handle case where no valid stats found.
3. prints -> print