Refactored line writing.