title: Ocaml print to file with newline
body: <p>I am trying to print the contents of a file to a new file line by line. However After running this function, only the last line of the input file is written to the output file. </p>
  
  <pre><code>let in_channel = open_in inFile in
  try
    while true do
      let line = input_line in_channel in
      let oc = open_out outFile in    
  
      fprintf oc "%s\n" line;  
  
      close_out oc;              
    done
    with End_of_file -&gt;
      close_in in_channel
  </code></pre>
  
  <p>What am I doing wrong? I am inputting the newline in the printf statement, so I am very confused. </p>