Modified split function to support splitting at keywords and line length in characters.