diff -U8 -rw flexi-streams-0.11.2.original/output.lisp flexi-streams-0.11.2/output.lisp
--- flexi-streams-0.11.2.original/output.lisp   2007-04-06 02:43:24.000000000 +0300
+++ flexi-streams-0.11.2/output.lisp    2007-04-21 20:49:43.251250000 +0300
@@ -255,70 +255,39 @@
           (t (loop for index from start below end
                    for element = (elt sequence index)
                    when (characterp element)
                    do (stream-write-char flexi-output-stream element)
                    else
                    do (stream-write-byte flexi-output-stream element))
              sequence))))
 
-(defmacro define-sequence-writer ((char-var stream-var stream-class) &body body)
-  "Helper macro to define methods for STREAM-WRITE-SEQUENCE.  Defines
-an optimized method for the class STREAM-CLASS \(which should use an
-8-bit encoding) and for sequences which are strings using the
-variables STREAM-VAR for the stream and CHAR-VAR for iterating through
-the string.  The code in BODY should return a character code
-corresponding to the character in CHAR-VAR."
-  (with-unique-names (sequence start end buffer index src-ptr dest-ptr)
-    `(defmethod stream-write-sequence ((,stream-var ,stream-class)
-                                       (,sequence string) ,start ,end &key)
-       "This method was generated with the DEFINE-SEQUENCE-WRITER macro."
-       (declare (optimize speed) (type (integer 0 *) ,start ,end))
-       (when (typep ,stream-var 'flexi-cr-mixin)
-         ;; refuse to optimize if line-end encoding is needed
-         (return-from stream-write-sequence (call-next-method)))
-       (let ((,buffer (make-array +buffer-size+ :element-type 'octet)))
-         ;; use repeated calls to WRITE-SEQUENCE for arrays of octets
-         (loop for ,index from ,start below ,end by +buffer-size+ do
-               (loop for ,src-ptr from ,index below ,end
-                     for ,dest-ptr from 0 below +buffer-size+
-                     for ,char-var = (aref ,sequence ,src-ptr)
-                     do (setf (aref ,buffer ,dest-ptr) (progn ,@body)))
-               (stream-write-sequence ,stream-var
-                                      ,buffer 0 (min +buffer-size+ (- ,end ,index))))
-         ;; find last #\Newline in string
-         (let ((newline-pos (position #\Newline ,sequence
-                                      :test #'char=
-                                      :start ,start
-                                      :end ,end
-                                      :from-end t)))
-           (setf (flexi-stream-column ,stream-var)
-                 (cond (newline-pos (- ,end newline-pos))
-                       ((flexi-stream-column ,stream-var)
-                        (+ (flexi-stream-column ,stream-var) (- ,end ,start)))))))
-       ,sequence)))
-
-(define-sequence-writer (char stream flexi-latin-1-output-stream)
-  (let ((octet (char-code char)))
-    (when (> octet 255)
-      (signal-encoding-error (flexi-stream-stream stream)
-                             "~S is not a LATIN-1 character." char))
-    octet))
+(defclass smart-vector-output-stream (vector-output-stream) ()
+  (:documentation  "Uses VECTOR-PUSH instead of VECTOR-PUSH-EXTEND 
+and doesn'tcheck whether stream is opened in STREAM-WRITE-BYTE. 
+All it for performance."))
 
-(define-sequence-writer (char stream flexi-ascii-output-stream)
-  (let ((octet (char-code char)))
-    (when (> octet 127)
-      (signal-encoding-error stream "~S is not an ASCII character." char))
-    octet))
+(defmethod stream-write-byte ((stream smart-vector-output-stream) byte)
+  "Writes a byte \(octet) by extending the underlying vector."
+  (declare (optimize speed))
+  (vector-push byte (vector-stream-vector stream)))
 
-(define-sequence-writer (char stream flexi-8-bit-output-stream)
-  (with-accessors ((encoding-hash flexi-stream-encoding-hash))
-      stream
-    (let ((octet (gethash (char-code char) encoding-hash)))
-      (unless octet
-        (signal-encoding-error stream "~S is not in this encoding." char))
-      octet)))
+(defmethod stream-write-sequence ((stream flexi-output-stream) (sequence string) start end &key)
+  (declare (optimize speed) (type (integer 0 *) start end src-ptr))
+  ;; use repeated calls to WRITE-SEQUENCE for arrays of octets
+  (let* ((buffer (make-array (+ +buffer-size+ 20) :element-type '(unsigned-byte 8) :fill-pointer 0))
+     (buf-stream (make-instance 'smart-vector-output-stream :vector buffer))
+     (tmp-flexi-stream (make-instance 'flexi-output-stream 
+                      :stream buf-stream 
+                      :flexi-stream-external-format (flexi-stream-external-format stream)
+                      :column (flexi-stream-column stream))))
+    (loop for index from start below end      
+      do (stream-write-char tmp-flexi-stream (aref sequence index))
+      when (>= (fill-pointer buffer) +buffer-size+) do (write-sequence buffer (flexi-stream-stream stream)) (setf (fill-pointer buffer) 0)
+      finally (when (>= (fill-pointer buffer) 0) (write-sequence buffer (flexi-stream-stream stream))))
+    (setf (flexi-stream-column stream) (flexi-stream-column tmp-flexi-stream)))
+  sequence)
 
 (defmethod stream-write-string ((stream flexi-8-bit-output-stream) string
                                 &optional (start 0) (end (length string)))
   "Use WRITE-SEQUENCE to output the string in cases where we might
 have an optimized method."
   (stream-write-sequence stream string start (or end (length string))))
diff -U8 -rw flexi-streams-0.11.2.original/stream.lisp flexi-streams-0.11.2/stream.lisp
--- flexi-streams-0.11.2.original/stream.lisp   2007-01-02 01:46:50.000000000 +0200
+++ flexi-streams-0.11.2/stream.lisp    2007-04-21 20:09:16.563750000 +0300
@@ -157,16 +157,17 @@
   "Dispatch to method for underlying stream."
   (declare (optimize speed))
   (setf (stream-file-position (flexi-stream-stream stream))
         position-spec))
 
 (defclass flexi-output-stream (flexi-stream fundamental-binary-output-stream
                                             fundamental-character-output-stream)
   ((column :initform 0
+      :initarg :column
            :accessor flexi-stream-column
            :documentation "The current output column.  A
 non-negative integer or NIL."))
   (:documentation "A FLEXI-OUTPUT-STREAM is a FLEXI-STREAM that
 can actually be instatiated and used for output.  Don't use
 MAKE-INSTANCE to create a new FLEXI-OUTPUT-STREAM but use
 MAKE-FLEXI-STREAM instead."))
 
diff -U8 -rw flexi-streams-0.11.2.original/test/test.lisp flexi-streams-0.11.2/test/test.lisp
--- flexi-streams-0.11.2.original/test/test.lisp    2007-03-09 03:14:30.000000000 +0200
+++ flexi-streams-0.11.2/test/test.lisp 2007-04-21 21:02:37.032500000 +0300
@@ -98,28 +98,40 @@
   (with-open-file (stream1 file1 :element-type 'octet)
     (with-open-file (stream2 file2 :element-type 'octet)
       (and (= (file-length stream1) (file-length stream2))
            (loop for byte1 = (read-byte stream1 nil nil)
                  for byte2 = (read-byte stream2 nil nil)
                  while (and byte1 byte2)
                  always (= byte1 byte2))))))
 
-(defun copy-stream (stream-in external-format-in stream-out external-format-out)
+(defun copy-stream-readline (stream-in external-format-in stream-out external-format-out)
   "Copies the contents of the binary stream STREAM-IN to the
 binary stream STREAM-OUT using flexi streams - STREAM-IN is read
 with the external format EXTERNAL-FORMAT-IN and STREAM-OUT is
 written with EXTERNAL-FORMAT-OUT."
   (let ((in (make-flexi-stream stream-in :external-format external-format-in))
         (out (make-flexi-stream stream-out :external-format external-format-out)))
     (loop for line = (read-line in nil nil)
           while line
           do (write-line line out))))
 
-(defun copy-file (path-in external-format-in path-out external-format-out direction-out direction-in)
+(defun copy-stream-read-sequence (stream-in external-format-in stream-out external-format-out)
+  "Copies the contents of the binary stream STREAM-IN to the
+binary stream STREAM-OUT using flexi streams - STREAM-IN is read
+with the external format EXTERNAL-FORMAT-IN and STREAM-OUT is
+written with EXTERNAL-FORMAT-OUT."
+  (let ((in (make-flexi-stream stream-in :external-format external-format-in))
+        (out (make-flexi-stream stream-out :external-format external-format-out))
+    (buf (make-array 100 :element-type 'character)))
+    (loop for end = (read-sequence buf in)
+          while (> end 0)
+          do (write-sequence buf out :end end))))
+
+(defun copy-file (copy-stream-fn path-in external-format-in path-out external-format-out direction-out direction-in)
   "Copies the contents of the file denoted by the pathname
 PATH-IN to the file denoted by the pathname PATH-OUT using flexi
 streams - STREAM-IN is read with the external format
 EXTERNAL-FORMAT-IN and STREAM-OUT is written with
 EXTERNAL-FORMAT-OUT.  The input file is opened with
 the :DIRECTION keyword argument DIRECTION-IN, the output file is
 opened with the :DIRECTION keyword argument DIRECTION-OUT."
   (with-open-file (in path-in
@@ -127,17 +139,17 @@
                       :direction direction-in
                       :if-does-not-exist :error
                       :if-exists :overwrite)
     (with-open-file (out path-out
                          :element-type 'octet
                          :direction direction-out
                          :if-does-not-exist :create
                          :if-exists :supersede)
-      (copy-stream in external-format-in out external-format-out))))
+      (funcall copy-stream-fn in external-format-in out external-format-out))))
 
 #+:lispworks
 (defun copy-file-lw (path-in external-format-in path-out external-format-out direction-out direction-in)
   "Same as COPY-FILE, but uses character streams instead of
 binary streams.  Only used to test LispWorks-specific behaviour."
   (with-open-file (in path-in
                       :external-format '(:latin-1 :eol-style :lf)
                       :direction direction-in
@@ -146,47 +158,49 @@
     (with-open-file (out path-out
                          :external-format '(:latin-1 :eol-style :lf)
                          :direction direction-out
                          :direction :output
                          :if-does-not-exist :create
                          :if-exists :supersede)
       (copy-stream in external-format-in out external-format-out))))
 
-(defun compare-files (path-in external-format-in path-out external-format-out)
+(defun compare-files (copy-stream-fn path-in external-format-in path-out external-format-out)
   "Copies the contents of the file (in the `test') denoted by the
 relative pathname PATH-IN to the file (in a temporary directory)
 denoted by the relative pathname PATH-OUT using flexi streams -
 STREAM-IN is read with the external format EXTERNAL-FORMAT-IN and
 STREAM-OUT is written with EXTERNAL-FORMAT-OUT.  The resulting
 file is compared with an existing file in the `test' directory to
 check if the outcome is as expected.  Uses various variants of
 the :DIRECTION keyword when opening the files."
   (let ((full-path-in (merge-pathnames path-in *this-file*))
         (full-path-out (ensure-directories-exist
                         (merge-pathnames path-out *tmp-dir*)))
         (full-path-orig (merge-pathnames path-out *this-file*)))
     (dolist (direction-out '(:output :io))
       (dolist (direction-in '(:input :io))
-        (format *error-output* "Test ~S ~S [~A]~% --> ~S [~A].~%" path-in
+        (format *error-output* "Test ~S ~A ~S [~A]~% --> ~S [~A].~%" path-in copy-stream-fn
                 (flex::normalize-external-format external-format-in) direction-in
                 (flex::normalize-external-format external-format-out) direction-out)
-        (copy-file full-path-in external-format-in
+        (copy-file copy-stream-fn
+           full-path-in external-format-in
                    full-path-out external-format-out
                    direction-out direction-in)
         (cond ((file-equal full-path-out full-path-orig)
                (incf *test-success-counter*))
               (t (format *error-output* " Test failed!!!~%")))
         (terpri *error-output*)
         #+:lispworks
         (format *error-output* "LW-Test ~S ~S [~A]~%    --> ~S [~A].~%" path-in
                 (flex::normalize-external-format external-format-in) direction-in
                 (flex::normalize-external-format external-format-out) direction-out)
         #+:lispworks
-        (copy-file full-path-in external-format-in
+        (copy-file copy-stream-fn
+           full-path-in external-format-in
                    full-path-out external-format-out
                    direction-out direction-in)
         #+:lispworks
         (cond ((file-equal full-path-out full-path-orig)
                (incf *test-success-counter*))
               (t (format *error-output* "    Test failed!!!~%")))
         (terpri *error-output*)))))
 
@@ -289,25 +303,44 @@
       (check (string= "aY" (using-values (#\Y)
                              (read-flexi-line `(,(char-code #\a) #x00 #x00 #x00 #x01) :utf-32le))))
       (check (string= "Y" (using-values (#\Y) (read-flexi-line `(#x01) :utf-32be))))
       (check (string= "Y" (using-values (#\Y) (read-flexi-line `(#x01 #x01) :utf-32be))))
       (check (string= "Y" (using-values (#\Y) (read-flexi-line `(#x01 #x01 #x01) :utf-32be))))
       (check (string= "aY" (using-values (#\Y)
                              (read-flexi-line `(#x00 #x00 #x00 ,(char-code #\a) #x01) :utf-32be)))))))
 
+(defun column-tracking-test()
+  (with-test ("Column tracking")
+    (let ((stream (make-flexi-stream (make-in-memory-output-stream) :external-format :utf-8)))
+      (write-char #\A stream)
+      (write-char #\B stream)
+      (write-char #\C stream)
+      (check (eql 3 (flex::stream-line-column stream)))
+      (write-char #\Newline stream)
+      (check (eql 0 (flex::stream-line-column stream)))
+      (write-string "abc" stream)
+      (check (eql 3 (flex::stream-line-column stream)))
+      (write-string (format nil "abc~Cd" #\Newline) stream)
+      (check (eql 1 (flex::stream-line-column stream))))))
+
 (defun run-tests ()
   "Applies COMPARE-FILES to all test scenarios created with
 CREATE-TEST-COMBINATIONS, runs test for handling of encoding errors,
 and shows simple statistics at the end."
   (let* ((*test-success-counter* 0)
          (args-list (loop for (file-name symbols) in *test-files*
                           nconc (create-test-combinations file-name symbols)))
-         (no-tests (* 4 (length args-list))))
+         (no-tests (* 8 (length args-list))))
     #+:lispworks
-    (setq no-tests (* 2 no-tests))
+    (setq no-tests (* 4 no-tests))
     (dolist (args args-list)
-      (apply #'compare-files args))
+      (apply #'compare-files 'copy-stream-readline args)
+      (apply #'compare-files 'copy-stream-read-sequence args))
+
     (incf no-tests)
     (encoding-error-handling-test)
+
+    (incf no-tests)
+    (column-tracking-test)
+
     (format *error-output* "~%~%~:[~A of ~A tests failed..~;~*All ~A tests passed~].~%"
             (= no-tests *test-success-counter*) (- no-tests *test-success-counter*) no-tests)))
-            