Improved error line number handling