title: How can I prepend an array value to the start of specific lines in a text file
body: <p>I want to prepend specific array values to the start of specific lines in a text file. </p>
  
  <p>For example if I have an array <code>animals=(cat, dog, bird, lizard)</code> and a text file that looks like this:</p>
  
  <pre><code>.color
  .age
  .size
  .breed
  .name
  
  .color
  .age
  .size
  
  .color
  .age
  .size
  .breed
  </code></pre>
  
  <p>How can I prepend cat to lines 1-5, dog to lines 6-8, bird to lines 9-13.
  (each animal has a different number of sections)</p>
  
  <p>The output text file should look like this:</p>
  
  <pre><code>cat.color
  cat.age
  cat.size
  cat.breed
  cat.name
  
  dog.color
  dog.age
  dog.size
  
  Bird.color
  Bird.age
  Bird.size
  Bird.breed
  </code></pre>
  
  <p>Any help is much appreciated :)</p>