What do you mean ".txt" format? If you mean make the text that your script output appear to have the same formatting as a .txt file would, you can either use HTML's <pre></pre> tags, or just output a plain text document and use [man]header/man to set the appropriate Content-type header (e.g. 'text/plain').