Improved tex file line handling