title: What am I missing to replace everything I want?
body: <p>I need 2 .txt files as parameters. The database.txt looks like this (in this format: name,address,date):<br>
  Michael,random street 1,dec.24.<br>
  Allen,random street 2,dec.24.<br>
  Kevin,random street 3,dec.24.  </p>
  
  <p>The text.txt file looks like an e-mail but the important parts are:<br>
  Name: /name/<br>
  Address: /address/<br>
  Date: /date/  </p>
  
  <p>I need to display the text.txt for every line of database.txt.
  Here is my code:  </p>
  
  <pre><code>param ( [Parameter(Mandatory=$True)][string] $textfile,
          [Parameter(Mandatory=$True)][string] $datafile )
  $text = get-content .\$textfile
  $data = get-content .\$datafile
  $name = ($data.Split(",")[0])
  $address = ($data.Split(",")[1])
  $date = ($data.Split(",")[2])
  
  foreach ($line in $textfile){
  
      $text -replace '/name/',$name
      $text -replace '/address/',$address
      $text -replace '/date/',$date
  }
  </code></pre>
  
  <p>The output looks like this:  </p>
  
  <p>Name : Michael<br>
  Address: /address/<br>
  Date: /date/ </p>
  
  <p>Name: /name/<br>
  Address: random street 1<br>
  Date: /date/  </p>
  
  <p>Name: /name/<br>
  Address: /address/<br>
  Date: dec.24.  </p>
  
  <p>It should be like this:  </p>
  
  <p>Name : Michael<br>
  Address: random street 1<br>
  Date: dec.24 </p>
  
  <p>Name: Allen<br>
  Address: random street 2<br>
  Date: dec.24  </p>
  
  <p>Name: Kevin<br>
  Address: random street 3<br>
  Date: dec.24. </p>
  
  <p>So my code recognizes only the first line and replaces the data at different times. What can I do to fix the issue? I think my foreach and/or split has something to do with it.<br>
  I am really new to powershell so try to keep the solution as simple as possible please. Thank you.</p>