Ensure that fwrite() behaves correctly when using memory streams. Reviewed-by: Carlos O'Donell <carlos@redhat.com>