Updating writeLines to ensure content length and encoding are set