Replace endl with \n to improve write performance