- Split writeXrefStream into smaller, focused functions
- Improve error handling and messages in xref related functions
- Enhance code readability and maintainability
- Use io.WriteString for more efficient string writing
This refactoring aims to make the xref stream writing process more modular, easier to understand, and slightly more efficient, while maintaining the existing functionality.