title: Using Erlang to read a whole text file into a variable, do text replacement and write modified file to new directory
body: <p>Problem: want to read content of a file (size less than 1MB) into a Erlang variable,
  do some text replacement and write modified contents to a new file. I am new to Erlang and
  want to use simple code with no error handling (use it from Erlang shell).</p>
  
  <p>I have tried:</p>
  
  <pre><code>File = file:read_file("pbd4e53e0.html").
  </code></pre>
  
  <p>But when using</p>
  
  <pre><code>string:len(File).
  </code></pre>
  
  <p>I get </p>
  
  <blockquote>
    <p>exception error: bad argument in function  length/1
    called as length({ok,&lt;&lt;">}) in call from string:len/1 (string.erl, line 66).</p>
  </blockquote>
  
  <p>Next step is to do replacement:</p>
  
  <pre><code>re:replace(File, "&lt;a href=\'pa", "&lt;a href=\'../pa/pa", [{return, list}]).
  </code></pre>
  
  <p>Question 1: How should I read the file into an Erlang variable?</p>
  
  <p>Question 2: Is the replacement ok?</p>