title: Encoding::UndefinedConversionError: "\x96" from ASCII-8BIT to UTF-8 error while writing to a file in ruby
body: <p>I am having a function which writes the filenames to a file in ruby.
  but I am getting this error:</p>
  
  <pre><code>Encoding::UndefinedConversionError: "\x96" from ASCII-8BIT to UTF-8
  </code></pre>
  
  <p>to overcome this is used:</p>
  
  <pre><code>file = File.open("names", "w")
  file.puts(filename.force_encoding("utf-8"))
  </code></pre>
  
  <p>doing this solved this problem, but when I am again reading through the file and try to open files whose <code>names</code> are stored in names file.
  I am getting an error saying <code>CANNNOT STAT: NO SUCH FILE OR FOLDER EXISTS</code>.</p>
  
  <p>any suggestions are welcome..!! </p>