%{
#include <stdio.h>
extern FILE *yyin, *yyout;  // External file pointers for input and output
%}

%% 
. { fprintf(yyout, "%s", yytext); }  // Print each matched character to output file
%% 

int main() {
    extern FILE *yyin, *yyout;

    // Open input.txt for reading and output.txt for writing
    yyin = fopen("input.txt", "r");
    if (!yyin) {
        perror("Error opening input file");
        return 1;
    }
    
    yyout = fopen("output.txt", "w");
    if (!yyout) {
        perror("Error opening output file");
        return 1;
    }

    yylex();  // Start lexical analysis
    fclose(yyin);  // Close input file after processing
    fclose(yyout); // Close output file after processing

    return 0;
}
