function read_words(filename)
//
// Read the contents of the given file.
//   Print out each word from the file onto the screen,
//   one word per line.
//   
// Arguments:
//      
//         filename          (input)  name of disk file to read
//                   

  // first, we try to open the file for reading
  fid = mopen(filename, 'r');
  if (fid == -1) 
    error('read_words: cannot open file for reading');
  end

  // read each word from the file, printing it to the screen as we go
  done_yet = 0;
  while (done_yet == 0)

    [num_read, line] = mfscanf(fid, "%s");
    if (num_read <= 0) 
      done_yet = 1;
    else
      // we put each word on a line by itself
      //    it would be nice to do this only at the end of each
      //    input line ... but how to tell?
      mprintf("%s\n", line);
    end
    
  end

  // remember to close the file before we return;
  mclose(fid);

endfunction
