slightly smarter method of writing newlines