title: Using Input/Output in SML
body: <p>I'm playing around with some Input/Output functions in SML, and I'm wondering if it's possible to copy specific content from one file to another, instead of copying the whole thing? </p>
  
  <p>Say that I have a function in one of the text files that returns a list of integers, and I just want to copy this result list into the empty output file. And if this is possible, how can I apply my copyFile function to copy the list automaticly to the output file?</p>
  
  <p>Here's the function I'm using for copy the whole text from one file to another: </p>
  
  <pre><code>fun copyFile(infile: string, outfile: string) =
    let
      val In = TextIO.openIn infile
      val Out = TextIO.openOut outfile
      fun helper(copt: char option) =
        case copt of
             NONE =&gt; (TextIO.closeIn In; TextIO.closeOut Out)
           | SOME(c) =&gt; (TextIO.output1(Out,c); helper(TextIO.input1 In))
    in
      helper(TextIO.input1 In)
    end
  </code></pre>