add valid header and rewrite screen output as file output