title: Setting yyout to file output in Lex is not working
body: <p>I created a program to append line numbers to the text file passed as an argument to the program. yyin is working fine, but yyout is not working i.e, contents are being read from the specified file, but nothing is being written to the output file instead the output is display to the console. </p>
  
  <pre><code>%option noyywrap
  %{
  #include&lt;stdio.h&gt;
  int linenumber=0;
  %}
  %%
  ^(.*)\n printf("%4d\t%s",++linenumber,yytext);
  %%
  int main()
  {
  yyin=fopen("test.c","r");
  yyout=fopen("result.txt","w");
  yylex();
  }
  </code></pre>