diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index 30a58b1..1b0900e 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -327,7 +327,7 @@ replace_typedefs_qualified_name (struct demangle_parse_info *info,
 		 string and replace the top DEMANGLE_COMPONENT_QUAL_NAME
 		 node.  */
 
-	      buf.rewind ();
+	      buf.clear ();
 	      n = cp_comp_to_string (&newobj, 100);
 	      if (n == NULL)
 		{
diff --git a/gdb/disasm.c b/gdb/disasm.c
index e29143ca..d84bd5c 100644
--- a/gdb/disasm.c
+++ b/gdb/disasm.c
@@ -240,7 +240,7 @@ gdb_pretty_print_insn (struct gdbarch *gdbarch, struct ui_out *uiout,
   if (name != NULL)
     xfree (name);
 
-  stb.rewind ();
+  stb.clear ();
   if (flags & DISASSEMBLY_RAW_INSN)
     {
       CORE_ADDR end_pc;
@@ -271,7 +271,7 @@ gdb_pretty_print_insn (struct gdbarch *gdbarch, struct ui_out *uiout,
     size = gdbarch_print_insn (gdbarch, pc, di);
 
   uiout->field_stream ("inst", stb);
-  stb.rewind ();
+  stb.clear ();
   do_cleanups (ui_out_chain);
   uiout->text ("\n");
 
diff --git a/gdb/guile/scm-ports.c b/gdb/guile/scm-ports.c
index 4f55e3c..fb3a47b 100644
--- a/gdb/guile/scm-ports.c
+++ b/gdb/guile/scm-ports.c
@@ -44,7 +44,6 @@ public:
   explicit ioscm_file_port (SCM port);
 
   void flush () override;
-  void rewind () override;
   void write (const char *buf, long length_buf) override;
 
 private:
@@ -449,12 +448,6 @@ ioscm_file_port::flush ()
 }
 
 void
-ioscm_file_port::rewind ()
-{
-  scm_truncate_file (m_port, 0);
-}
-
-void
 ioscm_file_port::write (const char *buffer, long length_buffer)
 {
   scm_c_write (m_port, buffer, length_buffer);
diff --git a/gdb/mi/mi-console.c b/gdb/mi/mi-console.c
index e3071a6..218ffbc 100644
--- a/gdb/mi/mi-console.c
+++ b/gdb/mi/mi-console.c
@@ -81,7 +81,7 @@ mi_console_file::flush ()
       gdb_flush (m_raw);
     }
 
-  m_buffer.rewind ();
+  m_buffer.clear ();
 }
 
 /* Change the underlying stream of the console directly; this is
diff --git a/gdb/mi/mi-console.h b/gdb/mi/mi-console.h
index 30569f1..a7962a8 100644
--- a/gdb/mi/mi-console.h
+++ b/gdb/mi/mi-console.h
@@ -41,12 +41,6 @@ public:
 
   void puts (const char *) override;
 
-  void write_buffer_on (ui_file &where) override
-  { m_buffer.write_buffer_on (where); }
-
-  void rewind () override
-  { gdb_assert_not_reached ("mi_console_file::rewind called\n"); }
-
 private:
   /* The wrapped raw output stream.  */
   ui_file *m_raw;
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 5e5289e..3c93553 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -1542,7 +1542,7 @@ mi_cmd_data_read_memory (char *command, char **argv, int argc)
 	      }
 	    else
 	      {
-		stream.rewind ();
+		stream.clear ();
 		print_scalar_formatted (&mbuf[col_byte], word_type, &opts,
 					word_asize, &stream);
 		uiout->field_stream (NULL, stream);
@@ -1553,7 +1553,7 @@ mi_cmd_data_read_memory (char *command, char **argv, int argc)
 	  {
 	    int byte;
 
-	    stream.rewind ();
+	    stream.clear ();
 	    for (byte = row_byte;
 		 byte < row_byte + word_size * nr_cols; byte++)
 	      {
diff --git a/gdb/mi/mi-out.c b/gdb/mi/mi-out.c
index 36db7a8..4b36edc 100644
--- a/gdb/mi/mi-out.c
+++ b/gdb/mi/mi-out.c
@@ -236,23 +236,31 @@ mi_ui_out::close (ui_out_type type)
   m_suppress_field_separator = false;
 }
 
+string_file *
+mi_ui_out::main_stream ()
+{
+  gdb_assert (m_streams.size () == 1);
+
+  return (string_file *) m_streams.back ();
+}
+
 /* Clear the buffer.  */
 
 void
 mi_ui_out::rewind ()
 {
-  ui_file_rewind (m_streams.back ());
+  main_stream ()->clear ();
 }
 
 /* Dump the buffer onto the specified stream.  */
 
 void
-mi_ui_out::put (ui_file *stream)
+mi_ui_out::put (ui_file *where)
 {
-  ui_file *outstream = m_streams.back ();
+  string_file *mi_stream = main_stream ();
 
-  outstream->write_buffer_on (*stream);
-  outstream->rewind ();
+  where->write (mi_stream->data (), mi_stream->size ());
+  mi_stream->clear ();
 }
 
 /* Return the current MI version.  */
@@ -265,13 +273,12 @@ mi_ui_out::version ()
 
 /* Constructor for an `mi_out_data' object.  */
 
-mi_ui_out::mi_ui_out (int mi_version, string_file *stream)
+mi_ui_out::mi_ui_out (int mi_version)
 : m_suppress_field_separator (false),
   m_suppress_output (false),
   m_mi_version (mi_version)
 {
-  gdb_assert (stream != NULL);
-
+  struct string_file *stream = new string_file ();
   m_streams.push_back (stream);
 }
 
@@ -284,9 +291,7 @@ mi_ui_out::~mi_ui_out ()
 mi_ui_out *
 mi_out_new (int mi_version)
 {
-  struct string_file *stream = new string_file ();
-
-  return new mi_ui_out (mi_version, stream);
+  return new mi_ui_out (mi_version);
 }
 
 /* Helper function to return the given UIOUT as an mi_ui_out.  It is an error
diff --git a/gdb/mi/mi-out.h b/gdb/mi/mi-out.h
index 26b6d72..fea94f2 100644
--- a/gdb/mi/mi-out.h
+++ b/gdb/mi/mi-out.h
@@ -30,7 +30,7 @@ class mi_ui_out : public ui_out
 {
 public:
 
-  explicit mi_ui_out (int mi_version, string_file *stream);
+  explicit mi_ui_out (int mi_version);
   virtual ~mi_ui_out ();
 
   /* MI-specific */
@@ -78,6 +78,11 @@ private:
   void open (const char *name, ui_out_type type);
   void close (ui_out_type type);
 
+  /* Convenience method that returns the MI out's string stream cast
+     to its appropriate type.  Assumes/asserts that output was not
+     redirected.  */
+  string_file *main_stream ();
+
   bool m_suppress_field_separator;
   bool m_suppress_output;
   int m_mi_version;
diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c
index 11fa83d..123a906 100644
--- a/gdb/tui/tui-disasm.c
+++ b/gdb/tui/tui-disasm.c
@@ -68,14 +68,14 @@ tui_disassemble (struct gdbarch *gdbarch, struct tui_asm_line *asm_lines,
       asm_lines->addr = pc;
       asm_lines->addr_string = xstrdup (gdb_dis_out.c_str ());
 
-      gdb_dis_out.rewind ();
+      gdb_dis_out.clear ();
 
       pc = pc + gdb_print_insn (gdbarch, pc, &gdb_dis_out, NULL);
 
       asm_lines->insn = xstrdup (gdb_dis_out.c_str ());
 
       /* Reset the buffer to empty.  */
-      gdb_dis_out.rewind ();
+      gdb_dis_out.clear ();
     }
   return pc;
 }
diff --git a/gdb/ui-file.c b/gdb/ui-file.c
index ea94cd2..60e3274 100644
--- a/gdb/ui-file.c
+++ b/gdb/ui-file.c
@@ -102,12 +102,6 @@ ui_file_isatty (struct ui_file *file)
 }
 
 void
-ui_file_rewind (struct ui_file *file)
-{
-  file->rewind ();
-}
-
-void
 ui_file_write (struct ui_file *file,
 		const char *buf,
 		long length_buf)
@@ -146,18 +140,6 @@ string_file::write (const char *buf, long length_buf)
   m_string.append (buf, length_buf);
 }
 
-void
-string_file::write_buffer_on (ui_file &where)
-{
-  where.write (m_string.data (), m_string.size ());
-}
-
-void
-string_file::rewind ()
-{
-  m_string.clear ();
-}
-
 
 
 stdio_file::stdio_file (FILE *file, bool close_p)
diff --git a/gdb/ui-file.h b/gdb/ui-file.h
index d3e0be2..3972d50 100644
--- a/gdb/ui-file.h
+++ b/gdb/ui-file.h
@@ -69,17 +69,6 @@ public:
 
   virtual void flush ()
   {}
-
-  /* The following two methods are meant to be overridden by
-     locally-buffered ui_files.  */
-
-  /* Rewind local buffer.  I.e., clear it.  */
-  virtual void rewind ()
-  {}
-
-  /* Write contents of local buffer onto WHERE.  */
-  virtual void write_buffer_on (ui_file &where)
-  {}
 };
 
 typedef std::unique_ptr<ui_file> ui_file_up;
@@ -99,8 +88,6 @@ extern null_file null_stream;
 
 extern void gdb_flush (ui_file *);
 
-extern void ui_file_rewind (struct ui_file *stream);
-
 extern int ui_file_isatty (struct ui_file *);
 
 extern void ui_file_write (struct ui_file *file, const char *buf,
@@ -127,10 +114,6 @@ public:
   long read (char *buf, long length_buf) override
   { gdb_assert_not_reached ("a string_file is not readable"); }
 
-  void rewind () override;
-
-  void write_buffer_on (ui_file &where) override;
-
   /* string_file-specific public API.  */
 
   /* Accesses the std::string containing the entire output collected
@@ -144,6 +127,7 @@ public:
   const char *c_str () const { return m_string.c_str (); }
   size_t size () const { return m_string.size (); }
   bool empty () const { return m_string.empty (); }
+  void clear () { return m_string.clear (); }
 
 private:
   /* The internal buffer.  */
@@ -186,9 +170,6 @@ public:
 
   bool isatty () override;
 
-  void rewind () override
-  { gdb_assert_not_reached ("can't rewind a stdio file"); }
-
 private:
   /* Sets the internal stream to FILE, and saves the FILE's file
      descriptor in M_FD.  */
@@ -262,9 +243,6 @@ public:
   bool isatty () override;
   void flush () override;
 
-  void rewind () override
-  { gdb_assert_not_reached ("tee_file::rewind called\n"); }
-
 private:
   /* The two underlying ui_files, and whether they should each be
      closed on destruction.  */
diff --git a/gdb/ui-out.c b/gdb/ui-out.c
index 97535060..42cffbe 100644
--- a/gdb/ui-out.c
+++ b/gdb/ui-out.c
@@ -535,7 +535,7 @@ ui_out::field_stream (const char *fldname, string_file &stream)
     field_string (fldname, stream.c_str ());
   else
     field_skip (fldname);
-  stream.rewind ();
+  stream.clear ();
 }
 
 /* Used to omit a field.  */
