use u() in the newline pattern
changed write_text to use newline patterns