title: Powershell How to combine multiple lines in to one with comma
body: <p>I have a very long list with 3 characters in each line like this</p>
  
  <pre><code>K2D
  K5K
  D9D
  ILO
  K5U
  T8K
  </code></pre>
  
  <p>How can I use powershell to combine this list into one line separated by comma like this</p>
  
  <p><code>K2D, K5K, D9D, ILO, K5U, T8K</code></p>
  
  <p>I can add comma at end of each line as below but don't know how to combine them into one line.</p>
  
  <pre><code>$list = get-content "list.txt"
  
  $result = "result.txt"
  
  $comma = foreach ($line in $list){
           $begein = ""
           $end = ","
           $begin + $line + $end
  }
  
  SET-CONTENT $result -value $comma
  </code></pre>