Check offset overflow before writing
Improve C lines output