title: How do I write the contents of a hash to a file in Ruby?
body: <p>I have a hash that looks as follows:</p>
  
  <pre><code>character = {"Name: " =&gt; "#$name", "Weapon: " =&gt; "#$weapon", "Armor: " =&gt; "#$armor"}
  </code></pre>
  
  <p>I want to print each <strong>key</strong> and each <strong>value</strong> to a file so that it looks something like this.</p>
  
  <p>Name: Templar<br>
  Weapon: Sword<br>
  Armor: Heavy Armor  </p>
  
  <p>I would like to use a basic method so that I understand what is going on. I've read that there are some modules that do this for you, such as Marshal, but I would like a basic method that involves beginner-level code.</p>