Refactored code for custom delimiter and also combined splitByComma and splitByNewline into splitByDelimiter function