#include <tads.h>
#include <file.h>

// Taken from MJR's T3 porting kit

main(args)
{
    local t = new TemporaryFile();
    "Temp file = <<t.getFilename()>>\n";

    local f = File.openTextFile(t, FileAccessWrite, 'ascii');
    for (local i in 1..10)
        f.writeFile('Test line #<<i>>!\n');
    f.closeFile();
    
    f = File.openTextFile(t, FileAccessRead, 'ascii');
    for (local i = 1 ;; ++i)
    {
        local l = f.readFile();
        if (l == nil)
            break;
        
        "<<sprintf('%06d %s\n', i, l)>>";
    }
    f.closeFile();
    
    // so we can see if the temporary file actually exists:
    inputKey();
}
