Changed encoding's loop to run until finished.