How to serialize/deserialize text editors and structures including text editors

You need to use write-editor-global-header, write-editor-global-footer when serializing and read-editor-global-header, read-editor-global-footer when deserializing. Here is a version of serialize-text / deserialize-text which work in your example:

(define (serialize-text text)
  (define editor-stream-out-bytes-base (new editor-stream-out-bytes-base%))
  (define editor-stream-out (make-object editor-stream-out% editor-stream-out-bytes-base))
  (write-editor-global-header editor-stream-out)
  (send text write-to-file editor-stream-out)
  (write-editor-global-footer editor-stream-out)
  (send editor-stream-out-bytes-base get-bytes))

(define (deserialize-text byte-stream)
  (define editor (new text% [auto-wrap #t]))
  (define editor-stream-in-bytes-base (make-object editor-stream-in-bytes-base% byte-stream))
  (define editor-stream-in (make-object editor-stream-in% editor-stream-in-bytes-base))
  (read-editor-global-header editor-stream-in)
  (send editor read-from-file editor-stream-in)
  (read-editor-global-footer editor-stream-in)
  editor)

Alex.