Corrected ending of output buffer to return the contents.