title: split the file into multiple files based on a string in spark scala
body: <p>I have a text file with the below data having no particular format</p>
  
  <pre><code>abc*123     *180109*1005*^*001*0000001*0*T*:~
  efg*05*1*X*005010X2A1~
  k7*IT 1234*P*234df~ 
  hig*0109*10052200*Rq~
  abc*234*9698*709870*99999*N:~
  tng****MI*917937861~
  k7*IT 8876*e*278df~
  dtp*D8*20171015~
  </code></pre>
  
  <p>I want the output as two files as below :</p>
  
  <p>Based on string <code>abc</code>, I want to split the file.</p>
  
  <p>file 1:</p>
  
  <pre><code>abc*123     *180109*1005*^*001*0000001*0*T*:~
  efg*05*1*X*005010X2A1~
  k7*IT 1234*P*234df~ 
  hig*0109*10052200*Rq~
  </code></pre>
  
  <p>file 2:</p>
  
  <pre><code>abc*234*9698*709870*99999*N:~
  tng****MI*917937861~
  k7*IT 8876*e*278df~
  dtp*D8*20171015~
  </code></pre>
  
  <p>And the file names should be IT name(the line starts with k7) so file1 name should be IT_1234 second file name should be IT_8876.</p>